一种有意思的加密解密



#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)

猜你喜欢

转载自cooler1217.iteye.com/blog/2208667