File tree 1 file changed +27
-0
lines changed
1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change
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
You can’t perform that action at this time.
0 commit comments