Skip to content

Commit feb4e40

Browse files
committed
add 0021
1 parent 345b0b1 commit feb4e40

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

llluiop/0021/password.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env python
2+
#-*- coding: utf-8-*-
3+
4+
5+
6+
import os
7+
from hashlib import sha256
8+
from hmac import HMAC
9+
10+
def encode(password):
11+
salt = os.urandom(8)
12+
print salt
13+
14+
result = password.encode("utf-8")
15+
16+
for i in range(10):
17+
result = HMAC(result, salt, sha256).digest()
18+
19+
return result
20+
21+
if __name__ == "__main__":
22+
password = "password"
23+
print encode(password)

0 commit comments

Comments
 (0)