# Function Needed for encoding text

1. ## Function Needed for encoding text

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.

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

2. ## Re: Function Needed

Your post does not comply with Rule 1 of our Forum RULES. Your post title should accurately and concisely describe your problem, not your anticipated solution. Use terms appropriate to a Google search. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will be addressed according to the OP's experience in the forum: If you have less than 10 posts, expect (and respond to) a request to change your thread title. If you have 10 or more posts, expect your post to be locked, so you can start a new thread with an appropriate title.
To change a Title on your post, click EDIT then Go Advanced and change your title, if 2 days have passed ask a moderator to do it for you.

3. ## Re: Function Needed for encoding text

Wow! you really know how to make a guy feel welcome.

4. ## Re: Function Needed for encoding text

We figure it's a reasonable trade that in exchange for free assistance we can expect people to read and follow the forum rules. You may prefer an unmoderated forum; there are several to choose from.

5. ## Re: Function Needed for encoding text

Originally Posted by wondering
... 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, ...
For a start, look up the MID function in Help, as in:
MID("abc",2,1)="b". You may also need the LEN() fn for loop control.

6. ## Re: Function Needed for encoding text

Perfect. I can break the message down, putting 1 letter in a different cell using: =MID(\$A\$8,1,1), =MID(\$A\$8,2,1), =MID(\$A\$8,3,1), etc. I figure I can eventually nest this inside a function to determine when the message ends. Thanks for your help.

There are currently 1 users browsing this thread. (0 members and 1 guests)

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1