public static SimpleDecryptWithPassword ( byte encryptedMessage, string password, int nonSecretPayloadLength ) : byte[] | ||
encryptedMessage | byte | |
password | string | |
nonSecretPayloadLength | int | |
return | byte[] |
public static string SimpleDecryptWithPassword(string encryptedMessage, string password, int nonSecretPayloadLength = 0) { if (string.IsNullOrWhiteSpace(encryptedMessage)) { throw new ArgumentException("Encrypted Message Required!", nameof(encryptedMessage)); } return(Encoding.UTF8.GetString(AESThenHMAC.SimpleDecryptWithPassword(Convert.FromBase64String(encryptedMessage), password, nonSecretPayloadLength))); }
public static byte[] DecryptDataWithPassword(byte[] encryptedBytesWithSalt, string passphrase) { try { return(AESThenHMAC.SimpleDecryptWithPassword(encryptedBytesWithSalt, passphrase, 2)); } catch (CryptographicException ex) { return((byte[])null); } catch (Exception ex) { return((byte[])null); } }
/// ---------------------------------------------------------------------------------------- /// <summary> /// Decrypt with password, key, salt using AES (Open SSL Decrypt).. /// </summary> /// ---------------------------------------------------------------------------------------- public static byte[] DecryptDataWithPassword(byte[] encryptedBytesWithSalt, string passphrase) { try { byte[] decryptedData = AESThenHMAC.SimpleDecryptWithPassword(encryptedBytesWithSalt, passphrase, nonSecretPayloadLength: 2); return(decryptedData); } catch (CryptographicException cex) { //return cex.Message; return(null); } catch (Exception ex) { //return ex.Message; return(null); } }