Created
June 25, 2015 12:57
-
-
Save uupaa/6b16bd6b5583bfbf54c7 to your computer and use it in GitHub Desktop.
Tiny Adler32
This file contains hidden or 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
| function Adler32(source) { | |
| var u32 = new Uint32Array([1, 0, source.length, 0, 0, 65521, 5550, 0]); | |
| while (u32[2] > 0) { | |
| u32[4] = u32[2] > u32[6] ? u32[6] : u32[2]; | |
| u32[2] -= u32[4]; | |
| do { | |
| u32[0] += source[u32[3]++]; | |
| u32[1] += u32[0]; | |
| } while (--u32[4]); | |
| u32[0] %= u32[5]; | |
| u32[1] %= u32[5]; | |
| } | |
| return ((u32[1] << 16) | u32[0]) >>> 0; | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment