-
Notifications
You must be signed in to change notification settings - Fork 1
/
flowerPassword3.py
executable file
·42 lines (33 loc) · 1.21 KB
/
flowerPassword3.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env python
# coding=utf8
# Flower Password Python Version.
# Author: xLsDg (xlsdg.github.com)
# Origin: http://www.flowerpassword.com/
# Usage: flowerPassword3.py KEY
import sys
import hmac
def generateFPCode(password, key, length = 16):
if (1 > len(password.strip())) or (1 > len(key.strip())) or (1 > length) or (length > 32):
return;
password = password.encode(encoding="utf-8");
key = key.encode(encoding="utf-8");
hmd5 = hmac.new(key, password).hexdigest().encode(encoding="utf-8");
rule = list(hmac.new("kise".encode(encoding="utf-8"), hmd5).hexdigest());
source = list(hmac.new("snow".encode(encoding="utf-8"), hmd5).hexdigest());
for i in range(0, 32):
if not(source[i].isdigit()):
if rule[i] in "sunlovesnow1990090127xykab":
source[i] = source[i].upper();
code = "".join(source[1:length]);
if not(source[0].isdigit()):
code = source[0] + code;
else:
code = "K" + code;
return code;
if __name__ == "__main__":
if len(sys.argv) != 2:
usage = "Usage: %s KEY\n" % (sys.argv[0]);
sys.stderr.write(usage);
sys.exit(1);
else:
print(generateFPCode("password", sys.argv[1]));