Password generator: Password format: password + space + character (randomly generated custom length) 10.1.1.1 %v! z{#2) 9g,-10.1.1.2 xwig;9zidn?} 10.1.1.3 ) [Email protected]10.1.1.4 sx<_? z.<yd9&10.1.1.5 y{zy[ym6z.,o10.1.1.6 [qbxibt37rcu10.1.1.7 ) Xs7t6[^NlDP10.1.1.8 h4cwo!! w8faz10.1.1.9 #; Vxi4lgawix10.1.1.10 e+6vm&kteb| " Write it directly into the file, open it can be used, a whole line is a password! To facilitate the initial deployment of salt batch generation SALT-SSH roster files when using # /usr/bin/env python# __*__coding:utf8__*__import Stringimport randomclass 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 + ' [email protected]#$%^&* () _+-=|} {[]; ", <>.? /' 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): &nBsp; 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): &nBsp;file = open (self.fname_password, ' R ') for line in file.readlines (): print line file.close () if __name__ == "__main__": len = int (raw_input (' Input password length: ') 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 ()
This article is from the "LINUX" blog, so be sure to keep this source http://wangpengtai.blog.51cto.com/3882831/1943714
Python Password generator