Login
7 branches 0 tags
Ben (X13/Arch) Fixed exceptions not being caught during stdlib loading 4082795 3 years ago 744 Commits
nujel / stdlib_modules / crypto / adler32.nuj
[export hash [defn hash [data]
                   [def a 1]
                   [def b 0]
                   [dotimes [i [string/length data]]
                            [set! a [mod/int [add/int a [char-at data i]] 65521]]
                            [set! b [mod/int [add/int a b] 65521]]]
                   [bit-or a [bit-shift-left b 16]]]]

[deftest "00620062" [fmt "{:08X}" [crypto/adler32/hash "a"]]]
[deftest "0F9D02BC" [fmt "{:08X}" [crypto/adler32/hash "asdQWE123"]]]
[deftest "796B110D" [fmt "{:08X}" [crypto/adler32/hash "DiesIstEinTestDerNujelAdler32Implementierung"]]]