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

Commit 648ad8a

Browse files
committed
hashing with screenshot updated
1 parent ae233e8 commit 648ad8a

File tree

2 files changed

+29
-17
lines changed

2 files changed

+29
-17
lines changed

Scripts/Miscellaneous/Hash_a_given_message/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,18 @@ pip install hashlib
1010
<!--Remove the below lines and add yours -->
1111
python hash.py
1212

13+
### Algorithms available
14+
blake2b blake2b512 blake2s
15+
blake2s256 md4 md5
16+
md5-sha1 mdc2 ripemd160
17+
sha1 sha224 sha256
18+
sha3-224 sha3-256 sha3-384
19+
sha3-512 sha384 sha3_224
20+
sha3_256 sha3_384 sha3_512
21+
sha512 sha512-224 sha512-256
22+
shake128 shake256 shake_128
23+
shake_256 sm3 whirlpool
24+
1325
### Screenshot/GIF showing the sample use of the script
1426
<!--Remove the below lines and add yours -->
1527
![Alt text](screenshot.png?raw=true "Title")
Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
11
import hashlib
2+
3+
24
def has():
3-
#List available algorithms
5+
# List available algorithms
46
print("Available algorithms are: ")
5-
q=sorted(list(hashlib.algorithms_available))
7+
q = sorted(list(hashlib.algorithms_available))
68
for i in range(len(q)):
7-
print('{0: <20}'.format(q[i]),end="")
8-
if i%3==2:
9+
print('{0: <20}'.format(q[i]), end="")
10+
if i % 3 == 2:
911
print()
10-
str2hash = list(input("Enter the names of the algorithms separated by space : ").split()) #Take input of algorithm names separated by space
11-
stri=input("Enter the message: ") #Enter the message to be encoded
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
1215
for i in str2hash:
13-
i=i.lower()
14-
15-
if i in list(hashlib.algorithms_available): #check whether names provided by user is valid or not
16-
result = hashlib.new(i)
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)
1720
result.update(stri.encode())
18-
print("The hexadecimal equivalent of "+i+" hash is : ", end ="")
21+
print("The hexadecimal equivalent of "+i+" hash is : ", end="")
1922
print(result.hexdigest())
2023
else:
2124
print(i+" is not a valid algorithm name")
2225

2326

2427
print("------Secure messages with hash--------")
2528
has()
26-
inp=input("Do you wish to continue?[y/n]")
27-
while inp.lower()=='y':
29+
inp = input("Do you wish to continue?[y/n]")
30+
while inp.lower() == 'y':
2831
has()
29-
inp=input("Do you wish to continue?[y/n]")
32+
inp = input("Do you wish to continue?[y/n]")
3033
print("Goodbye")
31-
32-
33-

0 commit comments

Comments
 (0)