-
Notifications
You must be signed in to change notification settings - Fork 8
/
Bacon.py
66 lines (32 loc) · 897 Bytes
/
Bacon.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!usr/bin/env python
# -*- coding:utf-8 -*-
from optparse import OptionParser
def Start():
start = OptionParser()
start.add_option('-p',dest='pw',help='Passwd')
start.add_option('-a',dest='getA',help='\'A\' word')
start.add_option('-b',dest='getB',help='\'B\' word')
options,args = start.parse_args()
if options.pw is None or options.getA is None or options.getB is None:
print 'Please input \'-h\' to get help'
exit(0)
return options
def Deal(options):
pw = options.pw.lower()
getA = options.getA
getB = options.getB
if len(pw)%5 != 0:
print 'Illegal passwd'
exit(0)
result = ''
for i in range(len(pw)/5):
string = pw[i*5:(i+1)*5]
string = string.replace(getA,'0')
string = string.replace(getB,'1')
result = result + chr(int(string,2)+97)
print result
def main():
options = Start()
Deal(options)
if __name__ == '__main__':
main()