We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ae9d0f9 commit 55b3088Copy full SHA for 55b3088
hashes/adler32.py
@@ -0,0 +1,27 @@
1
+"""
2
+ Adler-32 is a checksum algorithm which was invented by Mark Adler in 1995.
3
+ Compared to a cyclic redundancy check of the same length, it trades reliability for speed (preferring the latter).
4
+ Adler-32 is more reliable than Fletcher-16, and slightly less reliable than Fletcher-32.[2]
5
+
6
+ source: https://en.wikipedia.org/wiki/Adler-32
7
8
9
10
+def adler32(plain_text: str) -> str:
11
+ """
12
+ Function implements adler-32 hash.
13
+ Itterates and evaluates new value for each character
14
15
+ >>> adler32('Algorithms')
16
+ 363791387
17
18
+ >>> adler32('go adler em all')
19
+ 708642122
20
21
+ MOD_ADLER = 65521
22
+ a = 1
23
+ b = 0
24
+ for plain_chr in plain_text:
25
+ a = (a + ord(plain_chr)) % MOD_ADLER
26
+ b = (b + a) % MOD_ADLER
27
+ return (b << 16) | a
0 commit comments