Jan Dittberner
13b09a8844
git-svn-id: file:///home/www/usr01/svn/gnuviechadmin/gnuviech.info/gnuviechadmin/trunk@121 a67ec6bc-e5d5-0310-a910-815c51eb3124
25 lines
615 B
Python
25 lines
615 B
Python
#!/usr/bin/env python
|
|
|
|
import crypt, crack, popen2, random
|
|
|
|
def generate_password():
|
|
(o, i, e) = popen2.popen3("apg -n 1 -m 8 -x 12 -a 0")
|
|
|
|
return "".join(o.readlines()).strip()
|
|
|
|
def check_password(password):
|
|
try:
|
|
return crack.VeryFascistCheck(password)
|
|
except ValueError, ve:
|
|
print "Weak password:", ve
|
|
return None
|
|
|
|
def md5_crypt_password(password):
|
|
salt = "".join([chr(letter) for letter in random.sample(range(ord('a'), ord('z')), 8)])
|
|
|
|
return crypt.crypt(password, '$1$' + salt)
|
|
|
|
if __name__ == '__main__':
|
|
print check_password("test")
|
|
print generate_password()
|
|
print md5_crypt_password("test")
|