Skip to content

Commit 085eeba

Browse files
authored
Added Encryption and Password Hashing
1 parent 82de649 commit 085eeba

9 files changed

+316
-125
lines changed

SafeNotes/App.config

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@
4949
<setting name="setContrastTheme" serializeAs="String">
5050
<value>False</value>
5151
</setting>
52+
<setting name="setSaltedDecryptionKey" serializeAs="String">
53+
<value />
54+
</setting>
5255
</SafeNotes.Properties.Settings>
5356
</userSettings>
5457
</configuration>

SafeNotes/AppManager.cs

Lines changed: 201 additions & 97 deletions
Large diffs are not rendered by default.

SafeNotes/CustomConfig.cs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// File: SafeNotes/CustomConfig.cs
2+
using System;
3+
using System.IO;
4+
using Newtonsoft.Json;
5+
6+
namespace SafeNotes
7+
{
8+
public class CustomConfig
9+
{
10+
private static readonly string configFilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "SafeNotes", "config.json");
11+
12+
public string setUserPassword { get; set; }
13+
public string setYourName { get; set; }
14+
public string setEntryText { get; set; }
15+
public string notepadSaveText { get; set; }
16+
public bool setLightMode { get; set; }
17+
public bool setSaveDate { get; set; }
18+
public bool setIsUserLoggedIn { get; set; }
19+
public string setEntriesShow { get; set; }
20+
public string setEntriesHide { get; set; }
21+
public bool firstTimeOpened { get; set; }
22+
23+
public static CustomConfig Load()
24+
{
25+
if (File.Exists(configFilePath))
26+
{
27+
string json = File.ReadAllText(configFilePath);
28+
return JsonConvert.DeserializeObject<CustomConfig>(json);
29+
}
30+
return new CustomConfig();
31+
}
32+
33+
public void Save()
34+
{
35+
string json = JsonConvert.SerializeObject(this, Formatting.Indented);
36+
Directory.CreateDirectory(Path.GetDirectoryName(configFilePath));
37+
File.WriteAllText(configFilePath, json);
38+
}
39+
}
40+
}

SafeNotes/EventHandlers.cs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
public class EventHandlerClass
1010
{
11+
1112
public async Task CheckForUpdatesAsync()
1213
{
1314
string repo = "Thymester/SafeNotes";
@@ -30,13 +31,10 @@ public async Task CheckForUpdatesAsync()
3031
Version latestVersion = new Version(latestVersionString);
3132

3233
// Compare version numbers using the Version class
33-
if (latestVersion > currentAppVersion) // If the latest version is newer
34+
if (latestVersion > currentAppVersion)
3435
{
3536
var asset = release["assets"]?[0]?["browser_download_url"]?.ToString();
3637

37-
// Debug: Show the asset URL for checking
38-
MessageBox.Show($"Found update: {latestVersion}\nDownload URL: {asset}", "Update URL", MessageBoxButtons.OK, MessageBoxIcon.Information);
39-
4038
// Ensure that the asset is an .exe file
4139
if (asset != null && asset.EndsWith(".exe"))
4240
{
@@ -70,14 +68,14 @@ public async Task CheckForUpdatesAsync()
7068

7169
// Write the batch file for replacing the old version
7270
File.WriteAllText(batFilePath, $@"
73-
@echo off
74-
echo Update starting >> ""{logPath}""
75-
timeout /t 2 /nobreak > nul
76-
del /f /q ""{currentExePath}"" >> ""{logPath}"" 2>&1
77-
move /y ""{tempExePath}"" ""{currentExePath}"" >> ""{logPath}"" 2>&1
78-
start ""SafeNotes"" ""{currentExePath}""
79-
echo Update complete >> ""{logPath}""
80-
");
71+
@echo off
72+
echo Update starting >> ""{logPath}""
73+
timeout /t 2 /nobreak > nul
74+
del /f /q ""{currentExePath}"" >> ""{logPath}"" 2>&1
75+
move /y ""{tempExePath}"" ""{currentExePath}"" >> ""{logPath}"" 2>&1
76+
start ""SafeNotes"" ""{currentExePath}""
77+
echo Update complete >> ""{logPath}""
78+
");
8179

8280
// Launch the batch file to replace the app
8381
Process.Start(new ProcessStartInfo

SafeNotes/MainForm.Designer.cs

Lines changed: 44 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

SafeNotes/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@
2727
// it resets to zero and then increments the Major release. Bug releases are the typical release but can increment Minor releases if they are at 9 and the build is also at 9.
2828

2929
// Set version information for an assembly:
30-
[assembly: AssemblyVersion("1.3.3.0")] // MAJOR.MINOR.BUGS.BUILD
31-
[assembly: AssemblyFileVersion("1.3.3.0")] // MAJOR.MINOR.BUGS.BUILD
30+
[assembly: AssemblyVersion("1.3.5.0")] // MAJOR.MINOR.BUGS.BUILD
31+
[assembly: AssemblyFileVersion("1.3.5.0")] // MAJOR.MINOR.BUGS.BUILD

SafeNotes/Properties/Settings.Designer.cs

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

SafeNotes/Properties/Settings.settings

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,8 @@
4141
<Setting Name="setContrastTheme" Type="System.Boolean" Scope="User">
4242
<Value Profile="(Default)">False</Value>
4343
</Setting>
44+
<Setting Name="setSaltedDecryptionKey" Type="System.String" Scope="User">
45+
<Value Profile="(Default)" />
46+
</Setting>
4447
</Settings>
4548
</SettingsFile>

SafeNotes/SafeNotes.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@
131131
<Reference Include="WindowsBase" />
132132
</ItemGroup>
133133
<ItemGroup>
134+
<Compile Include="CustomConfig.cs" />
134135
<Compile Include="EntriesListBox.cs" />
135136
<Compile Include="AppManager.cs">
136137
<SubType>Form</SubType>

0 commit comments

Comments
 (0)