I am new to Java so bare with me! I would like to write my own trivial Cipher class so that I can encrypt message going back and forth from a client / server program that I have written.
The cipher algorithm is super simple. All I want to do is encode/ decode a character on its ASCII value according to the following:
encode:
160 - character's ascii value = encoded number
decode:
160 - encoded number = character's ascii value
eg I wish to send X
160 - asciiToChar(X) = encoded number
160 - 88 = 72
so the number 72 is sent from my client to my server.
simmarly, decryption:
160 - 72 = 88
charToAscii(88) is X
The class will obviously have two methods in it encode() and decode(). What I want to do is pass a String to this class which is either encoded or decoded into another string. I am guessing that the string will have to be converted into an array of chars to do the flip on each element, but am not sure how to go about it...
Any help?
The cipher algorithm is super simple. All I want to do is encode/ decode a character on its ASCII value according to the following:
encode:
160 - character's ascii value = encoded number
decode:
160 - encoded number = character's ascii value
eg I wish to send X
160 - asciiToChar(X) = encoded number
160 - 88 = 72
so the number 72 is sent from my client to my server.
simmarly, decryption:
160 - 72 = 88
charToAscii(88) is X
The class will obviously have two methods in it encode() and decode(). What I want to do is pass a String to this class which is either encoded or decoded into another string. I am guessing that the string will have to be converted into an array of chars to do the flip on each element, but am not sure how to go about it...
Any help?