Re: Encryption algorithm
From: LX-i (lxi0007_at_netscape.net)
Date: 01/09/04
- Previous message: Rich Chilausky: "Re: Novice Question About Console I/O"
- In reply to: Vik Mehta: "Encryption algorithm"
- Next in thread: Peter E.C. Dashwood: "Re: Encryption algorithm"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 08 Jan 2004 19:14:50 -0600
Vik Mehta 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.
There are several different things you could probably do... Some may
consider these "obscuring" rather than "encryption", but what you get
from these is worth every bit of what you're paying for them. :)
- ROT-13 - This can be done by Inspect...Converting.
Inspect My-String
Converting "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
to "NOPQRSTUVWXYZABCDEFGHIJKLM"
- Reversing - Again, Inspect...Converting.
Inspect My-String
Converting "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
to "ZYXWVUTSRQPONMLKJIHGFEDCBA"
Those two only work for letters - of course, the advantage to these is
that you run the string through the same algorithm to encode and decode.
There are some other options as well...
- You could convert the string to a 39-digit number by using a loop
combined with Function Ord (which you'd decode with Function Char).
01 My-39-Digit-Number.
12 My-3-Digits Occurs 13 Times Pic 9(03).
Perform Varying My-Idx from 1 by 1
Until My-Idx > 13
Move Function Ord (My-String (My-Idx:1))
to My-3-Digits (My-Idx)
End-Perform
This has the advantage of working with pretty much any character you'd
have in your ASCII character set.
If you wanted to get more fancy, you could strip the highest bit off,
making the characters 7 bits each, then cramming them all together.
Viewed in 8-bit format, it would look like junk, and it'll handle most
keyboard characters. Of course, that's a bit more complex, and without
knowing the environment you're in, it's more difficult to put together a
quick-and-dirty solution.
There is one more option - if you're using a database system that had
functions for one-way hashes (such as MD5 or SHA32), you can utilize
them from within your COBOL program.
Exec SQL
Select MD5(:My-String)
Into :My-Hash
From [Any_Table]
End-Exec
What exactly are you wanting to do with this encrypted string? That has
a lot to do with how you go about encrypting it. :)
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~ / \ / ~ Live from Montgomery, AL! ~ ~ / \/ o ~ ~ ~ / /\ - | ~ LXi0007@Netscape.net ~ ~ _____ / \ | ~ http://www.knology.net/~mopsmom/daniel ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ I do not read e-mail at the above address ~ ~ Please see website if you wish to contact me privately ~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Previous message: Rich Chilausky: "Re: Novice Question About Console I/O"
- In reply to: Vik Mehta: "Encryption algorithm"
- Next in thread: Peter E.C. Dashwood: "Re: Encryption algorithm"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
- End of String Character?
... string using some extended ASCII characters (ASCII code> 128) ... I am wondering
if there is a reserved character in VB that signifies ... the end of a string of
characters. ... Is my encryption algorithm possible generating a reserved character ...
(microsoft.public.scripting.vbscript) - Re: REWARD: chr() not working for Chinese "Locale"
... I have a routine that encrypts a string. ... >> value the encryption routine
generated for each character, ... > into a string which is likely to survive
whatever you throw at it. ... >> encryption routine tries to set a character to a
value in this range, ... (microsoft.public.pocketpc.developer) - Re: Encrypt/decrypt problem
... I didn't mean I wanted to encrypt/decrypt Chinese character. ... alphanumeric
but the encrypted string become 'alien' charater and no way to ... I also tried other encryption
FLL but result was the same. ... (microsoft.public.fox.programmer.exchange) - Re: Encryption algorithm
... Presumably you want the encryption as a COBOL Subroutine? ... [You can
set this key to be any character string you like. ... (comp.lang.cobol) - RfD: Escaped Strings version 4
... the S" string can only contain printable characters, ... the S" string cannot
contain the '"' character, ... as an escape character for the entry of characters
that cannot be ... \b BS (backspace, ASCII 8) ... (comp.lang.forth)