Created
September 18, 2017 14:30
-
-
Save i-e-b/c37cc2d728fe5e5a56205cd7e62d682c to your computer and use it in GitHub Desktop.
Adler32 hash in C#
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
private static uint Adler32(string str) | |
{ | |
const int mod = 65521; | |
uint a = 1, b = 0; | |
foreach (char c in str) { | |
a = (a + c) % mod; | |
b = (b + a) % mod; | |
} | |
return (b << 16) | a; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
you could probably implement this with
Span<byte>
to be encoding agnostic, but ty for putting this up in a gist!