Last active
December 20, 2022 18:43
-
-
Save drproteus/2dc2cff628cc5d9267d5ba2c7929c39b 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
#!python | |
import sys | |
MOD_ADLER = 65521 | |
def adler32(s): | |
a, b = 1, 0 | |
for c in s: | |
a = (a + ord(c)) % MOD_ADLER | |
b = (b + a) % MOD_ADLER | |
return hex(b << 16 | a)[2:] | |
if __name__ == "__main__": | |
for arg in sys.argv[1:]: | |
print(adler32(arg)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment