public static string Decrypt(string encryptedText, string password) { if (encryptedText == null) { return(null); } if (password == null) { password = String.Empty; } var bytesToBeDecrypted = Convert.FromBase64String(encryptedText); var passwordBytes = Encoding.UTF8.GetBytes(password); passwordBytes = SHA256.Create().ComputeHash(passwordBytes); var bytesDecrypted = Cryptology.Decrypt(bytesToBeDecrypted, passwordBytes); return(Encoding.UTF8.GetString(bytesDecrypted)); }
public static string Encrypt(this string password) { if (plainText == null) { return(null); } if (password == null) { password = String.Empty; } var bytesToBeEncrypted = Encoding.UTF8.GetBytes(plainText); var passwordBytes = Encoding.UTF8.GetBytes(password); passwordBytes = SHA256.Create().ComputeHash(passwordBytes); var bytesEncrypted = Cryptology.Encrypt(bytesToBeEncrypted, passwordBytes); password = Convert.ToBase64String(bytesEncrypted); return(password); }