Christian Damken
4259e5836b
- added command line option --mkpasswd to class argparser to hash a password - added a method to generate a SHA512-hash to asrc-server.py
32 lines
No EOL
658 B
Python
32 lines
No EOL
658 B
Python
# includes/auth.py
|
|
#
|
|
# module version: 0.0.20130617
|
|
# for protocol version 0.2.20130617
|
|
#
|
|
|
|
import hashlib
|
|
|
|
class auth:
|
|
|
|
passwd = ""
|
|
|
|
def init(password):
|
|
#from Crypto.Hash import Hash
|
|
|
|
global passwd
|
|
passwd = password
|
|
|
|
|
|
def check_passwd(incpass):
|
|
"""
|
|
checks a given password
|
|
"""
|
|
#return hashlib.sha512(incpass).hexdigest()
|
|
if hashlib.sha512(incpass).hexdigest() == passwd: return True
|
|
else: return False
|
|
|
|
def mkpasswd(incpass):
|
|
"""
|
|
encodes a password with SHA512
|
|
"""
|
|
return hashlib.sha512(incpass).hexdigest() |