Purpose: The Encrypt function encrypts data. The algorithm used to encrypt the data is designated by the Key parameter. It is the VTS analog of the CryptoAPI CryptEncrypt call.
Returns: Text
Usage: Script
Format: Encrypt(Key, PlainText, Final [, Reserved, Flags, Error])
Parameters: Key { handle } { required } { no default: }
The handle to the key to use to encrypt the data.
PlainText { text } { required } { no default: }
A text string that contains the plain text to be encrypted.
Final { Boolean } { required } { no default: }
A parameter that specifies whether this is the last section in a series being encrypted. Final is set TRUE for the last or only block and FALSE if there are more blocks to be encrypted
Reserved n/a
An optional parameter which should be set to 0. If omitted or invalid, then the value 0 is used.
Flags { numeric } { optional } { default: 0 }
An optional parameter specifying the flags to be passed to CryptEncrypt. If omitted or invalid then the value 0 is used. Refer to the Crypo API CryptEncrypt function for the flag list.
Error { numeric } { optional } { no default: }
An optional variable in which the error code for the function is returned. It has the following meaning:
|
Error |
Meaning |
|
0 |
Key successfully imported. |
|
1 |
Key, PlainText or Final parameters invalid. |
|
x |
Any other value is an error from CryptEncrypt. |
Comments: The cipher text is returned as a text string. If an error occurs, the return value is invalid.
Example:
[
PlainText1 = "abcdefghijklmnopqrstuvwxyz0123456789";
CipherText1;
]
Init [
If 1 Main;
[
CipherText1 = Encrypt(Key3, PlainText1, 1, 0, 0);
]
]
See Also:
DeriveKey | Decrypt | ExportKey | GenerateKey | GetCryptoProvider | GetKeyParam | ImportKey | SetKeyParam