Yet Another WebIOPi+
 All Classes Namespaces Files Functions Variables Macros Pages
crypto.py
Go to the documentation of this file.
1 import base64
2 import hashlib
3 from webiopi.utils.version import PYTHON_MAJOR
4 
5 def encodeCredentials(login, password):
6  abcd = "%s:%s" % (login, password)
7  if PYTHON_MAJOR >= 3:
8  b = base64.b64encode(abcd.encode())
9  else:
10  b = base64.b64encode(abcd)
11  return b
12 
13 def encrypt(value):
14  return hashlib.sha256(value).hexdigest()
15 
16 def encryptCredentials(login, password):
17  return encrypt(encodeCredentials(login, password))
def encryptCredentials
Definition: crypto.py:16
def encodeCredentials
Definition: crypto.py:5