Skip to content

Instantly share code, notes, and snippets.

@tombonner
Created June 29, 2017 14:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tombonner/08666ebd20b4f966477a3208470c0101 to your computer and use it in GitHub Desktop.
Save tombonner/08666ebd20b4f966477a3208470c0101 to your computer and use it in GitHub Desktop.
def petya_hash_process_name(name):
checksum = [0x78, 0x56, 0x34, 0x12]
i = 0
while i < 3:
j = i
for c in name:
checksum[j & 0x3] = abs((ord(c) ^ checksum[j & 0x3]) - 1)
j += 1
i += 1
return int("".join(["{:02x}".format(c) for c in reversed(checksum)]), 16)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment