Created
June 29, 2017 14:46
-
-
Save tombonner/08666ebd20b4f966477a3208470c0101 to your computer and use it in GitHub Desktop.
This file contains 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 characters
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