BO4E-dotnet.Encryption/SymmetricEncrypter.cs
/// <summary>
///     Decrypts a given cipher texts and checks if it corresponds to the associated data.
/// </summary>
/// <param name="cipherText">Base64 encoded encrypted bytes</param>
/// <param name="associatedDataString">max. 16 character long string (not secret)</param>
/// <param name="nonce">unique nonce used during encryption (not secret)</param>
/// <returns>decrypted as an UTF-8 encoded string</returns>
Decrypts a given cipher texts and checks if it corresponds to the associated data.
Decrypts a given cipher texts and checks if it corresponds to the associated data .
private string Decrypt(string cipherText, string associatedDataString, byte[] nonce)
        {
            var cipherBytes = Convert.FromBase64String(cipherText);
            var adBytes = Encoding.UTF8.GetBytes(associatedDataString);
            var plainBytes = SecretAeadChaCha20Poly1305.Decrypt(cipherBytes, nonce, _secretKey, adBytes);
            return Encoding.UTF8.GetString(plainBytes);
        }
private string Decrypt ( string cipherText , string associatedDataString , byte [ ] nonce ) { var cipherBytes = Convert . FromBase64String ( cipherText ) ; var adBytes = Encoding . UTF8 . GetBytes ( associatedDataString ) ; var plainBytes = SecretAeadChaCha20Poly1305 . Decrypt ( cipherBytes , nonce , _secretKey , adBytes ) ; return Encoding . UTF8 . GetString ( plainBytes ) ; }
Decrypts a given cipher texts and checks if it corresponds to the associated data.
Decrypts a given cipher texts and checks if it corresponds to the associated data .
decrypted as an UTF-8 encoded string
decrypted as an UTF - 8 encoded string
cipherText
string
Base64 encoded encrypted bytes
Base64 encoded encrypted bytes
associatedDataString
string
max. 16 character long string (not secret)
max . 16 character long string ( not secret )
nonce
byte[]
unique nonce used during encryption (not secret)
unique nonce used during encryption ( not secret )