Original Author Paul Laughton, 2011
Page 67
De Re BASIC!
If you supply the qualifier, whether password or charset, it IS case-sensitive.
If the source string cannot be encoded (or encrypted) with the specified charset (or password), the
function returns an empty string (""). You can call the GETERROR$() function to get an error message.
"ENCRYPT", "DECRYPT", and "URL" can be used on any BASIC! string. The string is converted to a byte
stream, then the byte stream is encrypted or URL-encoded. The encrypted byte stream is converted to
string format using the Base64 representation of binary data (see comment for "BASE64" in the table
above. URL-encoded strings do not require this extra step.
"ENCRYPT_RAW" and "DECRYPT_RAW" are intended for use with binary data in a buffer string. A buffer
string is a special use of the BASIC! string in which each 16-bit character consists of one byte of 0 and
one byte of data. "ENCRYPT_RAW" can encrypt a buffer string or an ASCII text string, but using it on
Unicode text will corrupt the string. After encryption, the result is returned in another buffer string.
"BASE64" also converts its string to a byte-stream before encoding it to Base64. The default conversion,
using UTF-8, works with any BASIC! string; specifying another character set encoding may corrupt data.
Normally, you would use "BASE64" on binary data in a buffer string. In this case, you may specify any
valid charset with no data corruption. The encoding string will change, but it can always be decoded
using the same charset.
See the two-parameter form of ENCODE$(), below, for a partial list of valid charsets.
DECODE$(<type_sexp>, {<qualifier_sexp>}, <source_sexp>)
Returns the result of decoding a string <source_sexp> that was encoded with ENCODE$(). The
<type_sexp>and <qualifier_sexp> describe how the string was encoded. You must use the same type
and qualifier that were used to encode the source string, or you may get unpredictable results.
Type
Qualifier
Default
Result
"ENCRYPT"
password
""
(empty)
Decrypts the source string using the password parameter. The
encryption algorithm is "PBEWithMD5AndDES". This usage of
DECODE$() works the same way as the DECRYPT command.
"DECRYPT"
password
""
Same as type "ENCRYPT" (decrypts, does not encrypt).
"ENCRYPT"
password
""
Same as type "DECRYPT" except the input and output are
buffer strings. This is useful for decrypting binary data.
"DECRYPT"
password
""
Same as type "ENCRYPT".
"URL"
charset
"UTF-8"
Decodes the source string assumed to be in the format
required by HTML
You should omit the charset parameter.
"BASE64"
charset
"UTF-8"
Decodes the source string holding the Base64 representation
of binary data. See RFCs
The type is required, but see below for the two-parameter form of ENCODE$() and DECODE$().
The type IS NOT case-sensitive: "BASE64", "base64", and "Base64" are all the same.
The qualifier is optional, but its comma is required.