I was having trouble encrypting a string of 36 characters using the Caesar Cypher. The Caesar cypher using a shift parameter to shift each alphabet a couple of characters so encrypt the code.
So a string of abcde, with a shift parameter of 3 would become, defgh.
Here's is a sample code of my encryption function:
Don't see anything. What are the 'random' values you get?
By the way, it would be a lot clearer if instead of plain[i]>=65 && plain[i]<=90 you wrote plain[i]>='A' && plain[i]<='Z'.
The values I'm getting are actually greater than 128 on the ASCII chart. Like for example, for a shift of 26 of "abcdefghijklmnopqrstuvwxyz" i should be getting the same thing over again. But i get "abcde" alright. The rest of characters are different. This does not happen when I'm dealing with capital alphabets which are from 65 to 90
I see now. 'z' = 122, if parameter = 6, shift = 128, which is in fact a negative number (google two's complement to see why). To solve this, make shift either unsigned of larger than a char.