Christian Damken
745c313fd5
- added passwd_request() and passwd_reply() to class comm - updated authentication process to fit protocol - fixed version numbers for each *.py-file
37 lines
635 B
Python
37 lines
635 B
Python
# includes/auth.py
|
|
#
|
|
# module version: 1.0.20130625
|
|
# for protocol version 0.2.20130625
|
|
#
|
|
#
|
|
# contains:
|
|
# init()
|
|
# check_passwd()
|
|
# mkpasswd()
|
|
#
|
|
|
|
|
|
import hashlib
|
|
|
|
class auth:
|
|
|
|
passwd = ""
|
|
|
|
def init(password):
|
|
|
|
global passwd
|
|
passwd = password
|
|
|
|
|
|
def check_passwd(incpass):
|
|
"""
|
|
checks a given password
|
|
"""
|
|
if hashlib.sha512(incpass).hexdigest() == passwd: return True
|
|
else: return False
|
|
|
|
def mkpasswd(incpass):
|
|
"""
|
|
encodes a password with SHA512
|
|
"""
|
|
return hashlib.sha512(incpass).hexdigest()
|