Skip to content

Commit 99c524b

Browse files
committed
Merge pull request Show-Me-the-Code#125 from llluiop/master
add 0021
2 parents 23e4551 + 38b9af4 commit 99c524b

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)