IB Statements/encrypt
From CometWiki
ENCRYPT function
Syntax: result-string = ENCRYPT(input-string, seed-string)
Discussion: The ENCRYPT function encrypts the input-string, and assigns the result to the result-string. The encryption algorithm uses the seed-string value as a seed.
The input-string may be defined at any length from 1 to 254 bytes. The ENCRYPT function returns the same number of bytes as the input-string.
The seed-string may be defined at any length from 1 to 254 characters. The value of the seed-string determines how the encryption algorithm transforms the input-string. (The seed-string value is also known as a "shared secret" between any application that encrypts data and any application that decrypts the same data.)
Note: The longer the seed string, the better the encryption. We recommend a minimum of 16 bytes for the seed string.
To decrypt the result-string, you must use the DECRYPT function and specify exactly the same seed-string (same length, same characters, same case) that was used to encrypt the data.
See DECRYPT.
History: This function was added to Comet98 in Build 266.
Example: LENGTH 25 & LOCAL A$, B$
LENGTH 16 & LOCAL SEED$
.
B$ = "Signature Systems, Inc."
SEED$ = "ABCD1234EFGH5678"
A$ = ENCRYPT(B$,SEED$)
In the above example, the value contained in B$ (the input-string) is encrypted using an encryption seed of "ABCD1234EFGH5678". The encrypted value is assigned to A$.
To decrypt A$, use the DECRYPT function with a seed of "ABCD1234EFGH5678".
Note: To accomplish stronger encryption, you can encrypt the seed-string itself. The following code shows how an initial value (SEED1$) and initial seed (SEED2$) are used to create an encrypted seed (SEED3$).
SEED1$ = "ABCD1234EFGH5678"
SEED2$ = "9999LKJI8765HGFE4321DCBA"
SEED3$ = ENCRYPT(SEED1$,SEED2$)
B$ = "Signature Systems, Inc."
A$ = ENCRYPT(B$,SEED3$)