internal void Delete() { string filename = Path.ChangeExtension(Base32.ToBase32String(SHA256.Create().ComputeHash(Encoding.UTF8.GetBytes(Name))), ".json"); string fullFilepath = Path.Combine(FileSystemConstants.PswmgrDataFolder, filename); if (File.Exists(fullFilepath)) { File.Delete(fullFilepath); } }
public string EncryptString(string unencryptedString, DataStorageFormat format = DataStorageFormat.Base64) { byte[] encrytedByteArray = m_rsa.Encrypt(Encoding.UTF8.GetBytes(unencryptedString), false); return(format == DataStorageFormat.Base64 ? Convert.ToBase64String(encrytedByteArray) : Base32.ToBase32String(encrytedByteArray)); }
public string ComputeHash(string filename) { byte[] allBytes = File.ReadAllBytes(filename); return(Base32.ToBase32String(SHA256.Create().ComputeHash(allBytes))); }