Re: Encryption algorithm
From: Judson McClendon (judmc_at_sunvaley0.com)
Date: 01/08/04
- Next message: Pierra: "Re: CoBOL moved to OO"
- Previous message: Howard Brazee: "Re: CoBOL moved to OO"
- In reply to: Vik Mehta: "Encryption algorithm"
- Next in thread: LX-i: "Re: Encryption algorithm"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 08 Jan 2004 16:58:42 GMT
"Vik Mehta" <aul1231@yahoo.com> wrote:
> I am looking for a simple encryption algorithm to encrypt a 13
> character alphanumeric string in a COBOL program. Any help will be
> appreciated.
How 'strongly' do you want to encrypt it? If you simply don't want it to
be read by casual observation, a technique similar to the one JerryMouse
proposed is sufficient. If you want it to resist analysis, you will need a
more powerful method.
For a simple character substitution method, reasonably secure from
casual decription, but vulnerable to analytical methods, run the
following QBASIC program. You can copy/past it Notepad or other
text editor for input into QBASIC or most any QuickBasic compatible
compiler or interpreter such as PowerBasic. Don't past it directly
into the BASIC IDE, or the indenting will get messed up. If you don't
have one, email me and I will send you a Windows/DOS executable.
---------------------------------------------------------------------
DIM Chars(255)
FOR I = 0 TO 255
Chars(I) = I
NEXT
OPEN "TRANTAB.COB" FOR OUTPUT AS #1
PRINT #1, " 01 TRANSLATION-STRING."
PRINT #1, " 03 TS-PLAIN."
FOR I = 0 TO 255
PRINT #1, " 05 FILLER PIC X(01) VALUE x"; CHR$(34); RIGHT$("0" + HEX$(Chars(I)), 2); CHR$(34); "."
NEXT
RANDOMIZE TIMER
FOR I = 0 TO 255
J = INT(RND * 256)
SWAP Chars(I), Chars(J)
NEXT
FOR I = 0 TO 255
J = INT(RND * 256)
SWAP Chars(I), Chars(J)
NEXT
PRINT #1, " 03 TS-ENCRIPTED."
FOR I = 0 TO 255
PRINT #1, " 05 FILLER PIC X(01) VALUE x"; CHR$(34); RIGHT$("0" + HEX$(Chars(I)), 2); CHR$(34); "."
NEXT
CLOSE #1
END
---------------------------------------------------------------------
which will create a disk file TRANTAB.COB containing a COBOL table
description like this:
01 TRANSLATION-STRING.
03 TS-PLAIN.
05 FILLER PIC X(01) VALUE x"00".
05 FILLER PIC X(01) VALUE x"01".
... (252 more entries, "02"-"FD")
05 FILLER PIC X(01) VALUE x"FE".
05 FILLER PIC X(01) VALUE x"FF".
03 TS-ENCRIPTED.
05 FILLER PIC X(01) VALUE x"C5".
05 FILLER PIC X(01) VALUE x"2F".
... (252 more random, unique entries)
05 FILLER PIC X(01) VALUE x"5F".
05 FILLER PIC X(01) VALUE x"72".
where the values under TS-ENCRIPTED are all the hex values 0-255
in random order. Each time you run the program you will get a different
sequence. This is to prevent anyone else from using this program to
easily decript your data. If your COBOL compiler doesn't accept the
x".." form of specifying hexidecimal literals, you will need to reformat
it for your compiler.
Copy the above 01 record into Working Storage of any program that
will encript or decript.
To encrypt a plain key use this:
INSPECT <field>
CONVERTING TS-PLAIN
TO TS-ENCRIPTED
To decrypt an encrypted key use this:
INSPECT <field>
CONVERTING TS-ENCRIPTED
TO TS-PLAIN
This should encript/decript any kind of data you can put in a PIC X(??)
data item.
-- Judson McClendon judmc@sunvaley0.com (remove zero) Sun Valley Systems http://sunvaley.com "For God so loved the world that He gave His only begotten Son, that whoever believes in Him should not perish but have everlasting life."
- Next message: Pierra: "Re: CoBOL moved to OO"
- Previous message: Howard Brazee: "Re: CoBOL moved to OO"
- In reply to: Vik Mehta: "Encryption algorithm"
- Next in thread: LX-i: "Re: Encryption algorithm"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|