破解栅栏密码python脚本

今天遇到一个要破解的栅栏密码,写了个通用的脚本

 1 #!/usr/bin/env python
 2 # -*- coding: gbk -*-
 3 # -*- coding: utf_8 -*-
 4 # Author: 蔚蓝行
 5 # http://www.cnblogs.com/duanv
 6 e = raw_input('请输入要解密的字符串\n')
 7 elen = len(e)
 8 field=[]
 9 for i in range(2,elen):
10             if(elen%i==0):
11                 field.append(i)
12 
13 for f in field:
14     b = elen / f
15     result = {x:'' for x in range(b)}
16     for i in range(elen):
17         a = i % b;
18         result.update({a:result[a] + e[i]})
19     d = ''
20     for i in range(b):
21         d = d + result[i]
22     print '分为\t'+str(f)+'\t'+'栏时,解密结果为:  '+d

 

posted @ 2015-05-21 22:08  荆书凝  阅读(6278)  评论(0编辑  收藏  举报