Octal Encryption
Here is the way nowdays I am encrypting my data It is simple and effective... Does any encryption-master knows how much effective :)
I don't know how much secure it is....to me it seems to be pretty good :) For the person who don't know passwd it will be difficult to factor Encrypt('python rules','anurag') = 74606416841240102050141401351134347444593601585502331623652940177646961 correctly when there is no unique prime factorisation
It converts 'python rules' to octal string and then replace \ by 8 or 9 similarly for passwd 'anurag' a number is generated both numbers are mutiplied to get encrypted string!
import random
#it just gets the octal representation of text and replace /
#by randomly 8 or 9 as octal doesn't have it
def OctalEncode(text):
s = ''
#convert to octal string representaion
for ch in text:
s = s +'\\%o'%(ord(ch))
es = ''
#replace / by 8 or 9
for ch in s:
if ch == '\\':
if random.randrange(2) == 0:
es=es+'8'
else:
es=es+'9'
else:
es=es+ch
return es
#replace 8 and 9 by / and u have ur string back
def OctalDecode(text):
ds = text.replace('8','\\')
ds = ds.replace('9','\\')
exec 'ds ="'+ds+'"'
return ds
#octal encode text and passwd and multiply
def Encrypt(text,passwd):
etext = long(OctalEncode(text))
epasswd = long(OctalEncode(passwd).replace('8','9'))#must be unique
e = etext*epasswd
return str(e)
#divide encode string by octal encode of passwd and u get ur string back
def Decrypt(etext,passwd):
epasswd = long(OctalEncode(passwd).replace('8','9'))#must be unique
e = long(etext)/epasswd
return OctalDecode(str(e))
es = Encrypt('python rules','anurag')
print es
print Decrypt(es,'anurag')