I need help writing a simple encryption scheme in ruby using a Substitution Ciph
ID: 3562061 • Letter: I
Question
I need help writing a simple encryption scheme in ruby using a Substitution Cipher. Each letter of the alphabet is assigned another... I need to do this using two parallel strings... just leave non-alphabetic characters alone so numbers, spaces, punctuation, etc. are not changed. I also need one function, encodeCharacter, that takes a string of length 1 (ch) and a cipher string and returns the character in the cipher string that corresponds to the ch according to the substitution cipher. I also need to do a little ASCII math to determine the cipher string index that the plaintext character corresponds to.. I attempted to do this but do not know if it is correct... I will put what I have so far below....I also need an encodeString( s, cipher) that takes string s and string cipher representing the substitution. It returns a new string that is s encoded according to the provided substitution cipher.
*encodeCharacter should be inside of encodeString, basically just a loop and some concatentation, passing rest of work onto encodeCharacter
Last I need to write decodeCharacter(ch, cipher) and decodeString(s, cipher) which will be similar to encodeCharacter()... the only difference will be the indexing ( as I said before the encode needs to have ASCII math)
* this is pretty basic stuff I just need it right away and do not have time, so if you could please help that would be great! (in a very timely manner) :)