useradd.py 585 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import os
import hashlib
import getpass

user = raw_input( "enter a user name: ")
passwd = False
confirm_passwd = None
while( passwd != confirm_passwd ):
    passwd = getpass.getpass( "enter a password: ")
    confirm_passwd = getpass.getpass( "confirm password: ")
    if passwd != confirm_passwd:
        print "passwords does not match"

h=hashlib.sha1()
Bertrand  NÉRON's avatar
BUG FIX    
Bertrand NÉRON committed
15
h.update( passwd )
16
17
18
19
20
21
22
23
salt = os.urandom(16).encode('hex')
h.update( salt )
print "\n##################"
print "new user = ", user
print "sha1 encrypted password = ", h.hexdigest()
print "salt = ", salt
print "##################"