Xbasic

A5_Encrypt_String Function

Syntax

Encoded_Text as C = a5_encrypt_string(C Source ,C Key [,C Algorithm [,B Initializer ]])

Arguments

Encoded_Text

The encoded string.

Source

The plain text string.

Key

The text used to encode SourceString.

Algorithm

Optional. Default = "Blowfish". Refer to Encryption Algorithms.

Initializer

Optional. Additional information to be provided by advanced users depending on the algorithm they use. Refer to the OpenSSL site at www.openssl.org for more information.

Description

Encrypts a string and returns the base64 encoded result. The A5_Encrypt_String() function encodes a character string.

? a5_encrypt_string("alpha software", "abc")
= "IwYGKelVPamJdy0XqlmEow=="
The underlying OpenSSL API may automatically pad an encryption/decryption key and may automatically truncate an initializer string. Be aware of this if you have a need to decrypt/encrypt data in an external program. For example, the default "Blowfish" algorithm uses a 16 byte key and an 8 byte initializer. You must supply your own initializer and pad your key if it is less than 16 bytes. Characters in XBasic are single byte. The following example will allow you to encrypt data in Alpha Anywhere and to decrypt it in a external program with the same key and initializer. Notice the spaces at the end of the key. The spaces are used as padding.
?a5_encrypt_string("SuPeRsEcReT     ", "Alpha Software", "blowfish", "63893756")
= "NS/yRgV0adCHGw4nLBukD0HSM4I/SPgV"

See Also