-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhash_functions.py
More file actions
48 lines (32 loc) · 1.45 KB
/
Copy pathhash_functions.py
File metadata and controls
48 lines (32 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import hashlib
# Below are the hash functions that are available to the user.
def hash_md5(password):
return hashlib.md5(password.encode()).hexdigest()
def hash_sha1(password):
return hashlib.sha1(password.encode()).hexdigest()
def hash_sha224(password):
return hashlib.sha224(password.encode()).hexdigest()
def hash_sha256(password):
return hashlib.sha256(password.encode()).hexdigest()
def hash_sha384(password):
return hashlib.sha384(password.encode()).hexdigest()
def hash_sha512(password):
return hashlib.sha512(password.encode()).hexdigest()
def hash_sha3_224(password):
return hashlib.sha3_224(password.encode()).hexdigest()
def hash_sha3_256(password):
return hashlib.sha3_256(password.encode()).hexdigest()
def hash_sha3_384(password):
return hashlib.sha3_384(password.encode()).hexdigest()
def hash_sha3_512(password):
return hashlib.sha3_512(password.encode()).hexdigest()
def hash_blake2b(password):
return hashlib.blake2b(password.encode()).hexdigest()
def hash_blake2s(password):
return hashlib.blake2s(password.encode()).hexdigest()
# SHAKE algorithms require a length parameter for the output hash
def hash_shake_128(password, length=128):
return hashlib.shake_128(password.encode()).hexdigest(length)
def hash_shake_256(password, length=256):
return hashlib.shake_256(password.encode()).hexdigest(length)
# Note: Users must specify the length for SHAKE algorithms when calling these functions