The QMEncrypt() function decrypts data for secure storage or transmission. It is analogous to the QMBasic ENCRYPT() function.
The QMEncrypt() function applies the AES 128 bit encryption algorithm to the supplied data and returns the encrypted text. The key string may be up to 64 characters in length and may contain any character. It is automatically transformed into a form that is usable by the AES algorithm. For optimum data security, the key should be a minimum of 16 characters though shorter keys can be used.
The encrypted data is structured so that it can never contain characters from the C0 control group (characters 0 to 31) or the mark characters. As a result of this operation, the encrypted data is slightly longer than the resultant decrypted data.
The QMEncryptx() function is similar but uses a random initialisation vector for improved security. This results in a small increase in the size of the encrypted data.
These functions are evaluated on the client system and do not require a server connection to be open.
The examples below encrypt the data in variable Var using an encryption key of "MyKey".