1
0
mirror of https://github.com/hashcat/hashcat.git synced 2025-03-10 20:46:05 +00:00
hashcat/tests/blake-test.py

33 lines
937 B
Python
Raw Normal View History

2023-02-06 15:51:53 +00:00
#!/usr/bin/python3
import hashlib
# Python script to create dataset of passwords/hashes for testing
PASSWD_FILE = "500-worst-passwords.txt"
VALID_HASHES_FILE = "blake2s-valid-hashes.txt"
BLAKE2S_HEADER = "$BLAKE2$"
# Password source file : https://github.com/danielmiessler/SecLists/blob/master/Passwords/500-worst-passwords.txt
def createBlake2sDataset(inputFile, outputFile):
# open password and hashes file
passwd = open(inputFile, 'r')
hashes = open(outputFile, 'w')
# for each password in file
for line in passwd.readlines():
# compute Blake2s hash
d = hashlib.blake2s()
d.update(line.encode())
# encode in base64 and write it
formattedHash = BLAKE2S_HEADER + d.hexdigest()
hashes.write(formattedHash + '\n')
print("Done")
def main():
createBlake2sDataset(PASSWD_FILE, VALID_HASHES_FILE)
# entry
if __name__ == "__main__":
main()