aboutsummaryrefslogtreecommitdiffstats
path: root/ddns/hash.py
blob: 7f74e25ab681d94be0fc73437146950fb6a4125f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import hashlib

def hash(algo, passwd):
	if algo == None:
		return passwd
	if algo == 'sha1':
		return sha1(passwd)
	if algo == 'sha256':
		return sha256(passwd)
	if algo == 'sha512':
		return sha512(passwd)
	return passwd

def sha1(passwd):
	return hashlib.sha1(passwd).hexdigest()

def sha256(passwd):
	return hashlib.sha256(passwd).hexdigest()

def sha512(passwd):
	return hashlib.sha512(passwd).hexdigest()