Link to home
Start Free TrialLog in
Avatar of formadmirer
formadmirerFlag for United States of America

asked on

VFP Encode / Decode Alpha Numeric String

Hi all. I need a way to encrypt / decrypt an alpha numeric string in vfp 9.

Someone here pointed me toward BITXOR a week or so ago and I am using that in one portion of the program and it works quite well.

However when the string is encoded it results in mostly in odd, unpronounceable characters. I need something that can be spoken, read over the telephone, sort of like a Microsoft key.

I would prefer something that will take a string consisting of both characters and numbers and produce a numeric result.
ASKER CERTIFIED SOLUTION
Avatar of Olaf Doschke
Olaf Doschke
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You can also generate an algorithm for coding and decoding based on the position of the letter and a password.

To maintain within capital alphabets you have to use MOD.

65+MOD(CHRValue,26)

MOD(nDividend, nDivisor)
While MOD puts values into a range of eg 0 to 25, you lose bits you will not be able to reconstruct. As far as I understand formadmirer, the whole process should be reversable to get back to the initial value.

you can do mod(28,26) and get 2, but also Mod(2,26) is 2. If you want to revert from 2 to the original, you can't decide, if the original was 28,2, or any other N*26+2. So you also have to store int(charValue/26). Base64 is already doing that, it spreads 3x8=24 bits into 4x6 bits.

Bye, Olaf.
Avatar of formadmirer

ASKER

This looks very usable and has some good information - thanks!
Here's one way to incorporate a password into chrtran encryption: Decompose it into it's bits and let each bit decide, wether to switch or not switch tow chars of ccEncrypt before using that for encryption.

You can make a block or stream cipher with it, by encoding lcMessage in blocks of N chars or each char individually.

There are many ideas, maybe you have your own. You could also XOR password chars again, but that will result in unreadable chars or control chars, whcih you want to avoid. My idea is to use the password as control data to shuffle your ccEncrypt translation string. Just make sure each char is in there once only and also make sure every char you want to encrypt is in there.

Bye, Olaf.