Skip to content
This repository was archived by the owner on Dec 22, 2023. It is now read-only.

Commit 8b06f59

Browse files
authored
Merge pull request #188 from ShravanBhat/hashing
Hash a given message using variety of algorithms
2 parents c3492a0 + 22bf0e5 commit 8b06f59

File tree

3 files changed

+55
-0
lines changed

3 files changed

+55
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Script Title
2+
<!--Remove the below lines and add yours -->
3+
Secure messages with hashing
4+
5+
### Prerequisites
6+
<!--Remove the below lines and add yours -->
7+
pip install hashlib
8+
9+
### How to run the script
10+
<!--Remove the below lines and add yours -->
11+
python hash.py
12+
13+
### Algorithms available
14+
blake2b, blake2b512, blake2s, blake2s256, md4, md5, md5-sha1, mdc2, ripemd160, sha1, sha224, sha256, sha3-224, sha3-256, sha3-384, sha3-512, sha384, sha3_224, sha3_256, sha3_384, sha3_512, sha512, sha512-224, sha512-256, shake128, shake256, shake_128, shake_256, sm3, whirlpool
15+
16+
### Screenshot/GIF showing the sample use of the script
17+
<!--Remove the below lines and add yours -->
18+
![Alt text](screenshot.png?raw=true "Title")
19+
20+
## *Author Name*
21+
<!--Remove the below lines and add yours -->
22+
Shravan
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import hashlib
2+
3+
4+
def has():
5+
# List available algorithms
6+
print("Available algorithms are: ")
7+
q = sorted(list(hashlib.algorithms_available))
8+
for i in range(len(q)):
9+
print('{0: <20}'.format(q[i]), end="")
10+
if i % 3 == 2:
11+
print()
12+
# Take input of algorithm names separated by space
13+
str2hash = list(input("Enter the algorithms separated by space: ").split())
14+
stri = input("Enter the message: ") # Enter the message to be encoded
15+
for i in str2hash:
16+
i = i.lower()
17+
# check whether names provided by user is valid or not
18+
if i in list(hashlib.algorithms_available):
19+
result = hashlib.new(i)
20+
result.update(stri.encode())
21+
print("The hexadecimal equivalent of "+i+" hash is : ", end="")
22+
print(result.hexdigest())
23+
else:
24+
print(i+" is not a valid algorithm name")
25+
26+
27+
print("------Secure messages with hash--------")
28+
has()
29+
inp = input("Do you wish to continue?[y/n]")
30+
while inp.lower() == 'y':
31+
has()
32+
inp = input("Do you wish to continue?[y/n]")
33+
print("Goodbye")
65.4 KB
Loading

0 commit comments

Comments
 (0)