36 lines
No EOL
951 B
C#
36 lines
No EOL
951 B
C#
using System;
|
|
using System.IO;
|
|
using System.Net;
|
|
using Avalonia.Data.Core;
|
|
|
|
namespace Cryptura;
|
|
|
|
public class Password
|
|
{
|
|
public string Name { get; set; }
|
|
public string Value { get; set; }
|
|
public string CensoredValue { get; set; } = "**********";
|
|
public WXFile WxFile { get; set; }
|
|
|
|
public string DisplayValue
|
|
{
|
|
get => MainWindow.censorPasswords ? CensoredValue : Value;
|
|
}
|
|
|
|
public Password(string name, string value)
|
|
{
|
|
this.Name = name;
|
|
this.Value = value;
|
|
this.WxFile = new WXFile(Path.Combine(Globals.GetKeyDirectory(), Globals.GenerateUuidFilename()));
|
|
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();
|
|
}
|
|
} |