I am playing around with creating a text encryption and decryption tool using mainly MS Excel and a little bit of MS Word. The version is 2003. I plan to use macros to prepare an unencrypted message, and for decoding an encrypted message.

My question at this point is: Is there a function which expands on "Code()". This function converts the 1st letter of a text string to its corresponding numerical value. Is there a way (either a function or some sort of workaround) to return the numerical value of the second letter of the text string (and the third, and the fourth, etc.).

If you are interested, here is the challenge I am working on (if not, you can skip this):

Create a workbook. List out all possible characters, numbered 1 to xxx. This would include uppercase, lowercase, numbers, and punctuation marks. Using the random number generator function, assign each letter a random number. Using the sort function, resort the data so that each letter now has a new randomly generated position in the alphabet. For example, If there are 150 different letter where A=1 a=2, B=3, b=4, etc. after they have been sorted, "A" has an equal chance of now being 1 - 150.

While this is a start, this type of code can easily be broken. So to make it more complicated, we can, from letter to letter. shift which key is used to determine what "A" equals. To creating more keys, we simply create a new worksheet page. and repeat the steps above. I would start with 10 pages of keys.

From there we break down the message letter by letter using the CODE() function. This is why i need to figure out how to look at the second and third position in a text string.

Once we have broken the message down to each letter, it is simply a matter of figuring out a way of choosing which key to use for each letter to encrypt the message. I was thinking of using a password, which only the sender and receiver know, which could help in choosing which key to use for which letter. Therefore, even if someone is able to obtain a copy of the workbook, the message would only make sense with the proper password.

For simplicity, lets say if the password is 5 letters long, use key #5 for the first letter, key #6 for the second letter, key #7 for the third letter, etc. If it is 10 letters long, start with key #10, etc. This way, the exact same message would be encoded (and decoded) differently depending on what the length of the password being used was.

Of course it is easy to make this more complicated, for example, possibly taking each letter in the password, giving it a numerical value multiplying it times 7, and dividing it by the length of the password, then rounding it up or down to get the corresponding key to be used.

If I can get the system this far, there are many things that can be added to further complicate the code. I think the first step would be to add nonsense letters into the code. If everything is one for one, at the very least, you can tell exactly how many characters are in the message. However, if 10 - 50% of the characters listed in the text are nonsense characters, then it is very hard to determine the true length of the message.

Of course, adding additional key pages would complicate the code exponentially.

Anyways, that's where I am at right now. Any help is appreciated.

## Bookmarks