Encrypt function
Syntax
Encrypt(KeyString, ClearTextString)
Description
Use the Encrypt function to encrypt a string. This function is generally used with merchant passwords.
The value you use for KeyString must be the same for Decrypt and Encrypt.
Parameters
| Parameter | Description |
|---|---|
|
KeyString |
Specify the key used for encrypting the string. You can specify a Null value for this parameter, that is, two quotation marks with no blank space between them (""). |
|
ClearTextString |
Specify the string you want encrypted. |
Returns
An encrypted string.
Example
The following encrypts a field if it contains a value. It also removes any blanks either preceding or trailing the value.
If All(PSCNFMRCHTOKEN.WRKTOKEN) Then
CMPAUTHTOKEN = Encrypt("", RTrim(LTrim(PSCNFMRCHTOKEN.WRKTOKEN)));
End-If;
Size Considerations for Encrypt
The Encrypt function uses 56-bit DES (Data Encryption Standard). The size of the output string is increased to the nearest multiple of 8 bytes. The string is encrypted (which doesn't modify the size), then encoded, which increases the resulting size to the next multiple of 3. Then, the system multiplies the result by 4/3 to get the final encrypted size.
For example, a 16-character, Unicode field is 32 bytes long, which is already an even multiple of 8. After it is encrypted, it is encoded, which increases the size of the string to 33 bytes (the next multiple of 3). Then, the system multiplies this by 4/3 to get the final encrypted string size of 44 bytes.