Skip to content
class method

Zlib.adler32

() -> ::Integer
(::String) -> ::Integer
(::String, ::Integer) -> ::Integer
Zlib.adler32(string, adler)

Calculates Adler-32 checksum for string, and returns updated value of adler. If string is omitted, it returns the Adler-32 initial value. If adler is omitted, it assumes that the initial value is given to adler. If string is an IO instance, reads from the IO until the IO returns nil and returns Adler-32 of all read data.

Example usage:

Example
require "zlib"

data = "foo"
puts "Adler32 checksum: #{Zlib.adler32(data).to_s(16)}"
#=> Adler32 checksum: 2820145
See also .adler32_combine .crc32 also in 4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0