2013-06-19 16:25:43 +02:00
|
|
|
# includes/auth.py
|
|
|
|
#
|
|
|
|
# module version: 0.0.20130617
|
|
|
|
# for protocol version 0.2.20130617
|
|
|
|
#
|
|
|
|
|
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):
|
|
|
|
#from Crypto.Hash import Hash
|
|
|
|
|
|
|
|
global passwd
|
|
|
|
passwd = password
|
|
|
|
|
|
|
|
|
|
|
|
def check_passwd(incpass):
|
|
|
|
"""
|
|
|
|
checks a given password
|
|
|
|
"""
|
2013-06-25 11:51:19 +02:00
|
|
|
#return hashlib.sha512(incpass).hexdigest()
|
|
|
|
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
|
|
|
|
"""
|
|
|
|
return hashlib.sha512(incpass).hexdigest()
|