Description
Decrypts a blob value with asymmetric algorithm.
Applies to
CrypterObject objects
Syntax
crypter.AsymmetricDecrypt ( algorithm, variable, privKey)
Argument |
Description |
---|---|
crypter |
The name of the CrypterObject object |
algorithm |
A value of the AsymmetricAlgorithm enumerated type that specifies the type of asymmetric algorithm. Values are:
Note: DSA! is designed to be used in signature, not in encryption and decryption. |
variable |
A blob whose value is the data you want to decrypt with Public-Key cipher. 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. |
privKey |
A blob specifying the private key. The private key format must be PKCS#8. |
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
This statement encrypts the data using RSA and then returns the encrypted data.
Blob lblb_data Blob lblb_privKey Blob lblb_pubKey Blob lblb_encrypt Blob lblb_decrypt lblb_data = Blob("Test Rsa", EncodingANSI!) CrypterObject lnv_CrypterObject lnv_CrypterObject = Create CrypterObject // Generate the private key lnv_CrypterObject.AsymmetricGenerateKey(RSA!, 1024, lblb_privKey, lblb_pubKey) // Encrypt data using RSA lblb_encrypt = lnv_CrypterObject.AsymmetricEncrypt(RSA!, lblb_data, lblb_pubKey) // Decrypt data using RSA lblb_decrypt = lnv_CrypterObject.AsymmetricDecrypt(RSA!, lblb_encrypt, lblb_privKey) messagebox("AsymmetricDecrypt", string(lblb_decrypt, EncodingANSI!))
See also