This commit is contained in:
WeeXnes 2025-05-06 02:34:07 +02:00
parent 9961b7792c
commit a6ebcf2c6c
4 changed files with 15 additions and 14 deletions

View file

@ -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
{

View file

@ -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();
}
}

View file

@ -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);
}
}
}

View file

@ -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