decrypt()
Decrypts the specified ciphertext using the specified passphrase.
Synopsis
int decrypt(blob ciphertext, string passphrase, string|blob
&plaintext);
Parameters
Parameter | Description |
---|---|
ciphertext | The container holding the encrypted data. |
passphrase | The passphrase to use for decryption. |
plaintext | The container to store the decrypted data. |
ErrorCode | Error code which indicates the success or failure of the operation. In the event of an error, the function returns negative values, otherwise the number of decrypted characters. |
Return Value
Error code which indicates the success or failure of the operation. In the event of an error, the function returns negative values, otherwise the number of decrypted characters.
Description
This method decrypts the specified ciphertext with the specified passphrase and saves the result in the specified plaintext.
Example
The example encrypts the given plaintext using the specified passphrase and configuration and decrypts the specified ciphertext using the specified passphrase.
public int test_AES_256_CBC_EncryptDecrypt_String()
{
const string plaintext = "Test encryption and decryption. Тест русских символов.";
const string passphrase = "akaSpUk0agC1P3f 测试中文字符和特殊字符";
const string cipherConfig = "AES_256_CBC__HMAC_SHA_3_256__PBKDF2_SHA_3_256__123456";
blob ciphertext;
int errorCode = encrypt(plaintext, passphrase, ciphertext, cipherConfig);
string decryptedText;
errorCode = decrypt(ciphertext, passphrase, decryptedText);
return 0;
}