I am trying to figure out the logic behind an encoder. That is how do encoders work? Thanks for any help!
An encoder would take in the normal text and output the encoded text i.e. the text with each character shifted the amount needed "My name is loubot" comes out as: "O bpcogbkubnqwdqv" with a shift of 2, M becomes O. So my code iterates through the original string gets the letter and adds 2 to it then adds this to a new string. When it gets to the end it has gone through all letters added 2 to them and created a new string which is shifted the correct amount.
First letter M add 2, becomes O add O to new string second letter y add 2, becomes ' ' (a space) add ' ' to new string
An even simpler way with just numbers is basically this: Alice has a number that she wants to tell Bob without letting Eve (who is in the same room) knowing what that number is. Before they went into that room, Alice had told Bob that the number will be 2 more than the real number. In the room Alice tells Bob the number 21. Since Bob knows that number is 2 larger than the actual one, he subtracts 2 from 21 and gets 19. The secret number Alice wanted to tell Bob. Loubot used the exact same concept except with letters. So if he told us 'C' we know that C is the 3rd letter in the alphabet, so we subtract 2 from 3 and we get 1, or 'A' the 1st letter in the alphabet.
Join our real-time social learning platform and learn together with your friends!