I was given a task to encrypt a string, but I must create my own encryption techniques.
I have an idea of how to do it. I can associate each value in a string with a number, like so:
A = 0
B = 1
...
And then I want to substitute characters for digits in the tens and higher: if I enter the string “DOG” it must display
3.46 // . is 1 and .. is 2
// .4 is 14
I would like hear your ideas.
I was given a visual basic form to work on. I can enter a string; that is fine.
Input = txtInputString.Text
But I also have to decrypt a string. To show I want to decrypt the string I have to have
string, false
, the false showing that i want to decrypt the string. How do i do this?
Encryption and decryption of simple English text is fairly quite forward if you use a simple method such as Ceasar Cipher.
However you have to determine how you are going to represent all of the symbols in the language. This would include not only letters but digits and spaces and maybe punctuation as well.
The standard ASCII character set has most of what you might need for English the question is whether you want to simplify your alphabet by restricting your symbols to only upper case letters, digits, and a space. Human beings can usually read text, especially short text even if it does not have punctuation.
The approach for a simple cipher would be to have a table of the symbols in your alphabet (the upper case letters, digits zero through nine, and a space character). Next rearrange the table so that it is not in sorted order.
When doing an encrypt you would take each character, look it up in the table and determine a two digit offset within the table. This two digit number would be the encryption symbol for that character and is what you would write out as part of the string of encryption.
When doing a decrypt you would take each two digit pair and use that as an offset into the table, find the character at that location in the table, and the write the character from the table out as part of the string of decryption.
Your encrypted string would be a series of two digit pairs all strung together as one long number.
For your form, I would expect to have two text entry groups each with a button, a text entry field, and a text display field. The first group would be for the text to encrypt and that button you would press to perform an encrypt once the text is entered. The encryption text would display in the field below the text entry field.
The second group would be the text to decrypt and that button you would press to perform a decrypt.