The main repository. Contains both Python and Javascript implementations.
修订版 | 321bd15ccd3bba860eca3fba9b3b3d0f1eb248ab (tree) |
---|---|
时间 | 2012-06-21 08:17:47 |
作者 | Eric Hopper <hopper@omni...> |
Commiter | Eric Hopper |
A small program to generate passwords for websites.
@@ -0,0 +1,18 @@ | ||
1 | +#!/usr/bin/python | |
2 | + | |
3 | +import binascii | |
4 | +import hmac | |
5 | +import hashlib | |
6 | +import getpass | |
7 | + | |
8 | +try: | |
9 | + readstr = raw_input | |
10 | +except NameError: | |
11 | + readstr = input | |
12 | + | |
13 | +hasher = hmac.HMAC(key=getpass.getpass().encode('utf-8'), | |
14 | + digestmod=hashlib.sha256) | |
15 | +sitename = readstr("Last two components of site name (aka slashdot.org): ") | |
16 | +hasher.update(sitename.encode('utf-8')) | |
17 | +result = binascii.b2a_base64(hasher.digest()).decode('ascii') | |
18 | +print('0' + result[0:5] + '*' + result[5:10] + 'l') |