Re: Encryption algorithm

From: LX-i (lxi0007_at_netscape.net)
Date: 01/09/04

  • Next message: LX-i: "Re: Encryption algorithm"
    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   ~
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    

  • Next message: LX-i: "Re: Encryption algorithm"

    Relevant Pages

    • Re: Microsoft.VisualBasic.Strings.Asc ?
      ... I'm trying to put together a simple utility to do rc4 encryption based on the rc4 algorithm here: ... You don't need to use Substring to access a single character in a string, and you don't need ToCharArray to convert a single character string to a character. ... Actually, the encryption methods in the .NET framework doesn't take strings at all, they encrypt streams of bytes, so the method should probably do the same and leave the encoding to the one using the method. ...
      (microsoft.public.dotnet.languages.csharp)
    • Re: simple string encryption
      ... which seems to be a fast and small xor encryption algorithm. ... string into a textbox and then read the string from the textbox ... The reason is because strings in VB use two bytes per character and your code, as it stands, is messing about with both bytes of each character. ...
      (microsoft.public.vb.general.discussion)
    • 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)
    • [TOMOYO #15 3/8] Common functions for TOMOYO Linux.
      ... This file contains common functions (e.g. policy I/O, pattern matching). ... Since TOMOYO Linux is a name based access control, ... TOMOYO Linux's string manipulation functions make reviewers feel crazy, ... the Linux kernel accepts all characters but NUL character ...
      (Linux-Kernel)