Skip to content

Instantly share code, notes, and snippets.

@Sparrow1029
Created March 24, 2019 23:09
Show Gist options
  • Select an option

  • Save Sparrow1029/99236d6bc263b113c32f7cce75e10e69 to your computer and use it in GitHub Desktop.

Select an option

Save Sparrow1029/99236d6bc263b113c32f7cce75e10e69 to your computer and use it in GitHub Desktop.

Revisions

  1. Sparrow1029 created this gist Mar 24, 2019.
    28 changes: 28 additions & 0 deletions genhash.py
    Original 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)