The Scramble Bytes (SCRAMBLE) command can be useful when you want to store sensitive data. The SCRAMBLE command does just what its name implies-it scrambles or unscrambles any character string, up to a length of 256. It doesn't actually encrypt the characters (e.g., character A will still be stored as an A); it only changes the order of the characters in the string. The scrambling is done by randomly shifting the order of the bytes within the source character string. If your sensitive data is comprised of short strings, you may want to consider some other encryption method.
The command processing program for this command is an RPG program. The program returns without setting on the LR indicator, so it is still active upon returning. The FREE command or the Reclaim Resources (RCLRSC) command can be used to deactivate the program. This command can be used only in a CL program.
Required Parameters
INPUT Specify the name of the CL program variable that contains the field to be scrambled, or specify the value to be scrambled. This must be defined as a *CHAR field and can be up to 256 bytes long.
OUTPUT Specify the name of the CL program variable that is to contain the scrambled field. This must be defined as a *CHAR field and must be the same length as the field or value in the INPUT parameter.
PROCESS Specify whether the value named in INPUT is to be scrambled or unscrambled.
*SCR: The value in INPUT is to be scrambled. The scrambled string is returned in the variable specified in OUTPUT.
*UNS: The value in INPUT is to be unscrambled. The unscrambled string is returned in the variable specified in OUTPUT. When this *UNS value is specified, the value in SCRCDE must be the same as when the value was scrambled.
LEN Specify the number of characters in INPUT that are to be scrambled. This must be less than or equal to the length of the field. Valid values range from 2 to 256.
SCRCDE Specify the scramble code that is used to control the scrambling and unscrambling process. The value may be given as a constant or a CL program variable. Any value may be specified for this string, encompassing character values from hex '00' to hex 'FF'. The same SCRCDE used to scramble the data must be used to unscramble it. SCRCDE must be defined as a *CHAR field, length 10.
Example
SCRAMBLE INPUT(&TEXTIN) + OUTPUT(&TEXTOUT) LEN(80) + SCRCDE('SCRAMBLE ')
This command scrambles bytes within field &TEXTIN and places the scrambled result into field &TEXTOUT. The INPUT and OUTPUT fields are 80 bytes long. The scramble code used is the word SCRAMBLE, followed by two blanks.
Source Members
INFO: SCRAMBLE (QATTINFO) CDO: TAACLPF (QATTCMD) CPP: TAACLPFR (QATTRPG)
LATEST COMMENTS
MC Press Online