How unsafe would be to publish the hash of my passwords?
I have written a Python script for helping me to remember my basic passwords (computer password, encrypted backup password, AppleID password, and KeyChain password).
It is hardcoded inside this:
SHA256(MD5(password) + password + MD5(password))
for each password and I periodically run it to keep my memory fresh.
I have a private repo on GitLab where I store all generic files and I would like to commit this script. I can't see any problem doing this since, as far as I know, it would be impossible to recover the original password, but I prefer to ask experts, to be sure.
EDIT: I'm adding an anonymized version of my script, so you can understand how it works:
from hashlib import md5, sha256
from getpass import getpass
from random import choice
def hash(pwd):
pwd = pwd.encode()
return sha256((md5(pwd).hexdigest()+str(pwd)+md5(pwd).hexdigest()).encode()).hexdigest()
dict = {'pass1': '6eaa49070c467d1edead2f6bc54cf42cdda11ae60d40aef2624a725871d3f452',
'pass2': '240cbc4ba2661b333f9ad9ebec5969ca0b5cf7962a2f18a45c083acfd85dd062',
'pass3': 'b018ed7bff94dbb0ed23e266a3c6ca9d1a1739737db49ec48ea1980b9db0ad46',
'pass3': '7dd3a494aa6d5aa0759fc8ea0cd91711551c3e8d5fb5431a29cfce26ca4a2682'
}
while True:
tipologia, hash_result = choice(list(dict.items()))
while True:
pwd = getpass(f'Password {tipologia}: ')
if hash(pwd) == hash_result:
print('Correct!')
break
else:
print('Wrong!')