SultanC
  1. Home
  2. Examples
  3. Cryptography

SHA-256 of a byte vector, printed as hexadecimal

crypto/sha256.sn
// SHA-256 of a byte vector, printed as hexadecimal.
import std.io.println;
import std.crypto.sha256;
import std.encoding.hex;

def main(): int {
    let input: vector u8 = [0x61, 0x62, 0x63];
    let digest: vector u8 = sha256(&input);
    println(hex_encode(&digest));
    return 0;
}

Run it

With the interpreter, without compiling:

./build/sultanc run examples/en/crypto/sha256.sn

Or compile it to an executable:

./build/sultanc examples/en/crypto/sha256.sn -o build/example && ./build/example

Source on GitHub   All examples