QMEncrypt()

Top  Previous  Next

 

The QMEncrypt() function decrypts data for secure storage or transmission. It is analogous to the QMBasic ENCRYPT() function.

 

 

Format

 

VBQMEncrypt(ByVal Data as String, ByVal KeyString as String) as String

 

Cchar * QMEncrypt(char * Data, char * KeyString)

 

where

 

Datais the data to be encrypted.

 

KeyStringis the encryption key to be used.

 

 

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 useable by the AES algorithm. For optimum data security, the key should be about 16 characters.

 

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.

 

Note that in the C API library, a statement of the form

rec = QMEncrypt(data, key)

will return a pointer to a newly allocated memory area that must be released using QMFree() when no longer needed.

 

This function is evaluated on the client system and does not require a server connection to be open.

 

 

Examples

 

VB

X = QMEncrypt("ABRACADABRA", "MyKey")

C

X = QMEncrypt("ABRACADABRA", "MyKey");

 

The above example encrypts the string "ABRACADABRA" using an encryption key of "MyKey".

 

 

See also:

QMDecrypt()