1 import md5
2 import struct
3 import binascii
4 count=8192
5
6 itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
7
8 def encode64(input,cnt=16):
9 output=''
10 i=0
11 while (i<cnt):
12 value = ord(input[i])
13 i = i+1
14 output = output + itoa64[value&0x3f]
15
16 if(i<cnt):
17 value |= ord(input[i])<<8
18 output = output + itoa64[(value>>6)&0x3f]
19
20 if(i >= cnt):break
21 i = i+1
22 if(i<cnt):
23 value |= ord(input[i])<<16
24 output = output + itoa64[(value>>12)&0x3f]
25
26 if(i >= cnt):break
27 i = i+1
28 output = output + itoa64[(value>>18)&0x3f]
29
30 return output
31 def decode64(input):
32 output=''
33 i=0
34 cnt = len(input)
35 value = 0
36 while (i<cnt):
37 value=itoa64.find(input[i])
38 i=i+1
39 if(i >= cnt):break
40 value |= itoa64.find(input[i])<<6
41
42 i=i+1
43 if(i >= cnt):break
44 value |= itoa64.find(input[i]) <<12
45
46 i=i+1
47 if(i >= cnt):break
48 value |= itoa64.find(input[i]) <<18
49 output = output + struct.pack('<I',value)[0:3]
50
51 i=i+1
52 return output+ struct.pack('<I',value)[0]
53
54 def wp_hash(salt,password):
55 hash=md5.md5(salt+password)
56
57 for i in range(count):
58 hash = md5.md5(hash.digest()+password)
59
60 print hash.hexdigest()
61 print encode64(hash.digest())
62
63 def bin2hex(input):
64 return ''.join('%02x' % ord(c) for c in input)
65 if __name__ == '__main__':
66 #test $P$Bat/4YEzkmzJMTWoFKaJlCOO1DAwUc.
67 # $P$ B at/4YEzk mzJMTWoFKaJlCOO1DAwUc.
68 #sign = '$P$'
69 #count = 1<<itoa64.index('B')
70
71 wp_hash('at/4YEzk','123456')
72 x=decode64('mzJMTWoFKaJlCOO1DAwUc.')
73 print bin2hex(x)
src: https://github.com/i3here/Web/tree/master
https://drive.google.com/file/d/0B3xt4Nh1OAl6VmVVcnNRc1I3aXM/edit?usp=sharing
没有评论:
发表评论