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 DecryptString(string encryptedString, DataStorageFormat format = DataStorageFormat.Base64) { byte[] encrytpedByteArray = format == DataStorageFormat.Base64 ? Convert.FromBase64String(encryptedString) : Base32.FromBase32String(encryptedString); byte[] byteArray = m_rsa.Decrypt(encrytpedByteArray, false); return(Encoding.UTF8.GetString(byteArray)); }
public string ComputeHash(string filename) { byte[] allBytes = File.ReadAllBytes(filename); return(Base32.ToBase32String(SHA256.Create().ComputeHash(allBytes))); }