Skip to content

Commit 8d9aa54

Browse files
authored
Added my own get_hash() function
1 parent 1032b1a commit 8d9aa54

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

usefulib/_usefulibs.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import string # generate_random_string()
1414
import uuid # generateUUID()
1515
import os # external_verbose_output()
16+
import hashlib # get_hash()
1617

1718
""""""
1819

@@ -133,4 +134,9 @@ def external_verbose_output(data, path="data.log"):
133134

134135
with open(path, "w") as f:
135136
f.write("# Logged by usefulibs.external_verbose_output()\n\n")
136-
f.write(data)
137+
f.write(data)
138+
def get_hash(string):
139+
"""
140+
@MKM12345 - This function takes a string as input, hashes it using the SHA-256 algorithm, and returns the hexadecimal representation of the hash value. Useful for developers that one to store strings without actually having to store them.
141+
"""
142+
return hashlib.sha256(string.encode('utf-8')).hexdigest()

0 commit comments

Comments
 (0)