From a6ebcf2c6c0799129cde60c422a221deb6fa1f85 Mon Sep 17 00:00:00 2001 From: WeeXnes Date: Tue, 6 May 2025 02:34:07 +0200 Subject: [PATCH] meh --- Cryptura/MainWindow.axaml.cs | 5 ++--- Cryptura/Password.cs | 12 ++++++------ Cryptura/Util.cs | 5 ----- Cryptura/WXFile.cs | 7 +++++++ 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/Cryptura/MainWindow.axaml.cs b/Cryptura/MainWindow.axaml.cs index ff7b710..2df7a97 100644 --- a/Cryptura/MainWindow.axaml.cs +++ b/Cryptura/MainWindow.axaml.cs @@ -31,7 +31,6 @@ public partial class MainWindow : Window InitializeComponent(); AdjustThemeToPlatform(); FetchPasswords(); - Password pw = new Password("monkeyman", "Himself"); } private void FetchPasswords(){ @@ -39,10 +38,10 @@ public partial class MainWindow : Window string[] WXFiles = Directory.GetFiles(Globals.GetKeyDirectory()); foreach (string file in WXFiles) { - if (Path.GetExtension(file).ToLower() == ".kf") + if (Path.GetExtension(file).ToLower() == ".wx") { Password pw = new Password(file); - pw.WxFile.Verify(); + passwords.Add(pw); } else { diff --git a/Cryptura/Password.cs b/Cryptura/Password.cs index 8723de0..b581680 100644 --- a/Cryptura/Password.cs +++ b/Cryptura/Password.cs @@ -22,15 +22,15 @@ public class Password this.Name = name; this.Value = value; this.WxFile = new WXFile(Path.Combine(Globals.GetKeyDirectory(), Globals.GenerateUuidFilename())); - this.WxFile.WriteHeader(); - this.WxFile.SetName(this.Name); - this.WxFile.SetValue(this.Value); + this.WxFile.CreateFromPassword(this); } public Password(string filepath) { - + this.WxFile = new WXFile(filepath); + if (!this.WxFile.Verify()) + throw new FormatException("Invalid WX File"); + this.Name = this.WxFile.GetName(); + this.Value = this.WxFile.GetValue(); } - - } \ No newline at end of file diff --git a/Cryptura/Util.cs b/Cryptura/Util.cs index 96dd2ca..cabfb60 100644 --- a/Cryptura/Util.cs +++ b/Cryptura/Util.cs @@ -30,12 +30,7 @@ public static class Util { if (!Directory.Exists(path)) { - Console.WriteLine("Directory " + path + " wasn't found, creating now."); Directory.CreateDirectory(path); } - else - { - Console.WriteLine("Directory was found: " + path); - } } } diff --git a/Cryptura/WXFile.cs b/Cryptura/WXFile.cs index 9a5fa30..0d7d851 100644 --- a/Cryptura/WXFile.cs +++ b/Cryptura/WXFile.cs @@ -12,6 +12,13 @@ namespace Cryptura this.Path = path; } + public void CreateFromPassword(Password password) + { + this.WriteHeader(); + this.SetName(password.Name); + this.SetValue(password.Value); + } + public bool Verify() { try