SultanC
  1. Home
  2. Examples
  3. Checksums

CRC-32 and Adler-32 checksums of the same bytes

checksum/checksums.sn
// CRC-32 and Adler-32 checksums of the same bytes.
import std.io.println;
import std.text.number;
import std.text.from_bytes;
import std.checksum.checksum;

def main(): int {
    let data: vector u8 = bytes_from_text("hello world");
    println(uint_to_text(crc32(&data) as uint));
    println(uint_to_text(adler32(&data) as uint));
    return 0;
}

Run it

With the interpreter, without compiling:

./build/sultanc run examples/en/checksum/checksums.sn

Or compile it to an executable:

./build/sultanc examples/en/checksum/checksums.sn -o build/example && ./build/example

Source on GitHub   All examples