In this post, I am going to talk about the basic fundamental and concepts of Cryptography. Let's start with Obfuscation and Encryption. In layman's language, encryption techniques are used to hide data or make is difficult to read. The term 'Crypto' become super popular because of the introduction of the currencies like Bitcoin, Litecoin, Ethereum etc. For us, it's just a form of protection, our focus will be on the cryptography applied to the communication, storage, messages etc. We will be using Python for the code nuggets. Lets start with the 'Caesar Cipher' and 'ROT13'
Caesar Cipher: It's an old trick where you just move every letter forward three character in the alphabet.
Plain Text - abcdefghijklmnopqrstuvwxyz
Cipher Text - defghijklmnopqrstuvwxyzabc
For example:
hello = khoor
Lets implement this in python!
Caesar Cipher: It's an old trick where you just move every letter forward three character in the alphabet.
Plain Text - abcdefghijklmnopqrstuvwxyz
Cipher Text - defghijklmnopqrstuvwxyzabc
For example:
hello = khoor
Lets implement this in python!
beta = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#GETTING User Input
user_input = raw_input("Enter a message in Capital Letters")
#Calculating String Length
n = len(user_input)
str_out = ""
for i in range(n):
c = user_input[i]
loc = beta.find(c)
print i ,c,loc,
newloc = loc +3
str_out += beta[newloc]
print newloc, str_out
print "Obfuscated Version:", str_out
ROT13 will do the shift by '13' instead of '3'