Created
March 24, 2019 23:09
-
-
Save Sparrow1029/99236d6bc263b113c32f7cce75e10e69 to your computer and use it in GitHub Desktop.
Revisions
-
Sparrow1029 created this gist
Mar 24, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,28 @@ #!/usr/bin/env python3 import hashlib import whirlpool import sys algo = sys.argv[1] target = sys.argv[2] def gen_hash(algo, target): candidate = 0 if algo == 'md5': hash_algo = lambda x: hashlib.md5(x.encode('ascii')).hexdigest() elif algo == 'sha1': hash_algo = lambda x: hashlib.sha1(x.encode('ascii')).hexdigest() elif algo == 'whirlpool': hash_algo = lambda x: whirlpool.new(x.encode('ascii')).hexdigest() while True: plaintext = str(candidate) hs = hash_algo(plaintext) if hs[:len(target)] == target: print(f"plaintext: {plaintext}, {algo} hash: {hs}") break candidate += 1 gen_hash(algo, target)