首页 > 代码库 > Python密码生成器
Python密码生成器
密码生成器: 密码格式为:密码+空格+字符(随机产生自定义长度) 10.1.1.1 %V!Z{#2)9G,- 10.1.1.2 xWIg;9zIdn?} 10.1.1.3 )PRRQiKU@oCj 10.1.1.4 sX<_?Z.<yd9& 10.1.1.5 Y{Zy[ym6z.,O 10.1.1.6 [qbXiBt37Rcu 10.1.1.7 )Xs7t6[^NlDP 10.1.1.8 H4CwO!!W8fAZ 10.1.1.9 #;VXI4lgawIx 10.1.1.10 e+6VM&KTEb|" 直接将其写到文件里面,打开即可以使用了,一整行都是密码!为了方便初次部署salt批量生成salt-ssh的roster文件时候使用 # /usr/bin/env python # __*__coding:utf8__*__ import string import random class PASSWORD(object): def __init__(self,len, fname_iplist, fname_password): self.len = len self.fname_iplist = fname_iplist self.fname_password = fname_password def CreatePassword(self): iplist = [] password = [] letters = string.digits + string.ascii_letters + ‘!@#$%^&*()_+-=|}{[];",<>.?/‘ file = open(self.fname_iplist, ‘r‘) for ip in file.readlines(): iplist.append(ip.replace(‘\n‘, ‘ ‘)) file.close() for ip in iplist: # print ip password.append(ip) for i in range(self.len): password.append(random.choice(letters)) password.append(‘\n‘) # print password password_list = ‘‘.join(password).split(‘\n‘) # print password_list file = open(self.fname_password, ‘wb+‘) for line in password_list: print line file.write(line + ‘\n‘) file.close() def DisplayPassword(self): file = open(self.fname_password, ‘r‘) for line in file.readlines(): print line file.close() if __name__ == "__main__": len = int(raw_input(‘输入密码长度:‘)) fname_iplist = ‘/home/wangpengtai/Desktop/iplist.txt‘ fname_password = ‘/home/wangpengtai/Desktop/password.txt‘ p = PASSWORD(len, fname_iplist, fname_password) p.CreatePassword() p.DisplayPassword()
本文出自 “LINUX” 博客,请务必保留此出处http://wangpengtai.blog.51cto.com/3882831/1943714
Python密码生成器
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。