Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Uncategorized category for Simple Hashlib by Mahoter
import hashlib
import codecs
def checkio(hashed_string, algorithm):
txt = str(hashed_string)
txt = txt.encode('utf8')
if algorithm == "md5":
m = hashlib.md5()
if algorithm == "sha224":
m = hashlib.sha224()
if algorithm == "sha256":
m = hashlib.sha256()
if algorithm == "sha384":
m = hashlib.sha384()
if algorithm == "sha512":
m = hashlib.sha512()
if algorithm == "sha1":
m = hashlib.sha1()
m.update(txt)
return m.hexdigest()
if __name__ == '__main__':
#These "asserts" using only for self-checking and not necessary for auto-testing
assert checkio('welcome', 'md5') == '40be4e59b9a2a2b5dffb918c0e86b3d7'
assert checkio('happy spam', 'sha224') == '6e9dc3e01d57f1598c2b40ce59fc3527e698c77b15d0840ae96a8b5e'
Jan. 18, 2016