Description
Decrypts a blob value using symmetric algorithm.
Applies to
CrypterObject objects
Syntax
crypter.SymmetricDecrypt ( algorithm, variable, key{, operationmode{, iv{, padding}}})
Argument |
Description |
---|---|
crypter |
The name of the CrypterObject object. |
algorithm |
A value of the SymmetricAlgorithm enumerated type that specifies the type of symmetric algorithm. Values are:
|
variable |
A blob whose value is the data you want to decrypt with symmetric algorithm. When using the system blob function to convert a string to a blob, it is recommended to specify its encoding argument to be EncodingANSI! (for English characters only) or EncodingUTF8!, otherwise, the default EncodingUTF16LE! will be used. |
key |
A blob specifying the secret key. The length of the secret key can be 128 bits, 192 bits, 256 bits with AES. The length of the secret key must be 64 bits with DES. The length of the secret key can be 128 bits, 192 bits with TDES. The length of the secret key must be 192 bits with DESX. The length of the secret key can be 32 bits~448 bits with Blowfish. |
operationmode (optional) |
A value of the OperationMode enumerated type that specifies the mode of operation. Values are:
|
iv (optional) |
A blob specifying the initialization vector. Zeros filled by default. In the AES algorithm, the effective length of the iv is 16 bytes and the others are 8 bytes. If the length is not enough, it will be automatically filled with zeros. In the ECB operation mode, the iv will be ignored. |
padding (optional) |
A value of the PaddingScheme enumerated type that specifies the padding schemes used for block cipher. Values are:
ZerosPadding!, PKCSPadding!, and OneAndZerosPadding! can be used with ECB and CBC operation mode. NoPadding! can be used with CFB, OFB and CTR operation mode. |
Return value
Blob.
Returns the result of the decrypt if it succeeds. If any argument's value is null, the method returns null. If an error occurs, throw the exception.
Examples
The following statements encrypt the data using AES and then decrypt the data using AES.
Blob lblb_data Blob lblb_key Blob lblb_iv Blob lblb_encrypt Blob lblb_decrypt lblb_data = Blob("Test AES", EncodingANSI!) lblb_key = Blob("Test Key12345678", EncodingANSI!) lblb_iv = Blob("Test IV 12345678", EncodingANSI!) CrypterObject lnv_CrypterObject lnv_CrypterObject = Create CrypterObject // Encrypt data using AES lblb_encrypt = lnv_CrypterObject.SymmetricEncrypt(AES!, lblb_data, lblb_key, & OperationModeCBC!, lblb_iv, PKCSPadding!) // Decrypt data using AES lblb_decrypt = lnv_CrypterObject.SymmetricDecrypt(AES!, lblb_encrypt, lblb_key, & OperationModeCBC!, lblb_iv, PKCSPadding!) messagebox("SymmetricDecrypt", string(lblb_decrypt, EncodingANSI!))
See also