2013-06-19 16:25:43 +02:00
|
|
|
# includes/auth.py
|
|
|
|
#
|
2013-06-25 14:03:28 +02:00
|
|
|
# module version: 1.0.20130625
|
|
|
|
# for protocol version 0.2.20130625
|
2013-06-19 16:25:43 +02:00
|
|
|
#
|
2013-06-25 14:03:28 +02:00
|
|
|
#
|
|
|
|
# contains:
|
|
|
|
# init()
|
|
|
|
# check_passwd()
|
|
|
|
# mkpasswd()
|
|
|
|
#
|
|
|
|
|
2013-06-19 16:25:43 +02:00
|
|
|
|
2013-06-25 11:51:19 +02:00
|
|
|
import hashlib
|
|
|
|
|
2013-06-19 16:25:43 +02:00
|
|
|
class auth:
|
2013-06-25 11:51:19 +02:00
|
|
|
|
2013-06-19 16:25:43 +02:00
|
|
|
passwd = ""
|
|
|
|
|
|
|
|
def init(password):
|
|
|
|
|
|
|
|
global passwd
|
|
|
|
passwd = password
|
|
|
|
|
|
|
|
|
|
|
|
def check_passwd(incpass):
|
|
|
|
"""
|
|
|
|
checks a given password
|
|
|
|
"""
|
2013-06-25 11:51:19 +02:00
|
|
|
if hashlib.sha512(incpass).hexdigest() == passwd: return True
|
2013-06-19 16:25:43 +02:00
|
|
|
else: return False
|
2013-06-25 11:51:19 +02:00
|
|
|
|
|
|
|
def mkpasswd(incpass):
|
|
|
|
"""
|
|
|
|
encodes a password with SHA512
|
|
|
|
"""
|
2013-06-25 14:03:28 +02:00
|
|
|
return hashlib.sha512(incpass).hexdigest()
|