欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

一种有意思的加密解密

程序员文章站 2022-03-12 12:54:25
...



#encoding=utf-8
'''
Created on 2014-12-9

@author: cooler
'''
#加密过程:
head = "4"
end = "F"
oldstr = "68f7284f61557429af55dfa1"
serial = (int(head,16) + int(end,16))%13
newstr = oldstr[serial:24] + oldstr[0:serial]
authstr = head + newstr + end
print "oldstr = ",oldstr
print "newstr = ", newstr
print "authstr = " , authstr
print serial
print "-----------------------------"
#解密函数:
def decodeAuth(authstr):
print "authstr = " , authstr
head = authstr[0]
end = authstr[25]
serial = (int(head,16) + int(end,16))%13
print serial
oldstr = authstr[1:25]
print " auth[1]-----auth[24] ",oldstr
newstr = oldstr[(24-serial):24] + oldstr[0:(24-serial)]
print "_auth[1]------_auth[24] ", newstr
print "dname = ",newstr[0:12]
print "uname = ",newstr[12:24]
return newstr
decodeAuth(authstr)