Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.

Beginners ROT-3 in C


ghost's Avatar
0 0

Hi

I started learning C, and decided (maybe foolishly) that I would try and write a so called 'ceaser cipher' as one of my first programs. However, I got stuck when trying to assign the numbers to my alphabet. I had thought of using the unicode values but I read somewhere they arnt the same on all systems (or locales?). I dont have my original source, it did nothing more than read the characters to be encrypted anyway.

Can anyone quickly draft some pseudocode or something to explain how simple encryption ciphers work?

Thanks in advance,


ghost's Avatar
0 0

jjbutler88 wrote: However, I got stuck when trying to assign the numbers to my alphabet.

I'd use the hex values of the letters (a=61 etc) as then you just read in chars and treat them as hex. You then add 13 (or whatever your encryption is) and just need to decide whether you are sticking to alphanumeric (in which case you obviously want to loop back to 61h if you exceed 5Bh).

Good luck with it.


ghost's Avatar
0 0

just do a foreach on the character string and have another string containing the rot13 version, which you add to depending on the value of each character. :)


ghost's Avatar
0 0

Thanks all, especially JohnDoe. I didnt expect anyone to actually code me an example! I will expand on the example to create better encryption schemes and repost them to HBH (providing the government hasnt shut us down! :()