forked from gil9red/SimplePyScripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathavailable.py
More file actions
29 lines (21 loc) · 673 Bytes
/
Copy pathavailable.py
File metadata and controls
29 lines (21 loc) · 673 Bytes
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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
__author__ = "ipetrash"
import hashlib
import sys
algorithms = list(hashlib.algorithms_available) # get list algorithms
algorithms.sort()
print(f"Algorithms available: {', '.join(algorithms)}")
text = input("Text: ")
if not text:
print("Empty text!")
sys.exit(1)
alg_name = input("Name algorithm: ")
if alg_name not in algorithms: # search in list
print("Algorithm not found!")
sys.exit(1)
alg = hashlib.new(alg_name) # create hash function from name
alg.update(text.encode()) # set data in hash-function
print("Result:")
print(f" hex: {alg.hexdigest()}")
print(f" HEX: {alg.hexdigest().upper()}")