Skip to content

Instantly share code, notes, and snippets.

@caffeinatedgaze
Last active November 4, 2020 09:37
Show Gist options
  • Save caffeinatedgaze/3038238e51d96ab967828519ffc08c11 to your computer and use it in GitHub Desktop.
Save caffeinatedgaze/3038238e51d96ab967828519ffc08c11 to your computer and use it in GitHub Desktop.
BITMASK32 = int('0xffffffff', 16)
def hash_name(name):
if any([ord(x) < ord('A') for x in name]):
return 1
out = []
for each in name:
if ord(each) >= ord('Z'):
sub = ord(each) - 0x20
out.append(sub)
else:
out.append(ord(each))
hashsum = sum(out) & BITMASK32
return hashsum ^ 0x5678
def hash_pass(pswd):
hashsum = 0
for each in pswd:
hashsum *= 0xa
hashsum += ord(each) - 0x30
hashsum &= BITMASK32
return hashsum ^ 0x1234
def generate_key(hash_n):
for i in range(1000000):
if hash_pass(str(i)) == hash_n:
return str(i)
def main():
name = input()
hashed_n = hash_name(name)
print('hashed_n', hex(hashed_n))
pswd = generate_key(hashed_n)
print('pswd', pswd)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment