SHA-256 of a byte vector, printed as hexadecimal
// 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;
}// ملخص SHA-256 لمتجه بايتات مطبوعا بالنظام الست عشري.
استورد std.io.println;
استورد std.crypto.sha256;
استورد std.encoding.hex;
عرف الرئيسية(): عدد {
دع المدخل: متجه ط8 = [0x61, 0x62, 0x63];
دع الملخص: متجه ط8 = شا256(&المدخل);
اطبع_سطر(رمز_سداسي(&الملخص));
أرجع 0;
}
Run it
With the interpreter, without compiling:
./build/sultanc run examples/en/crypto/sha256.snOr compile it to an executable:
./build/sultanc examples/en/crypto/sha256.sn -o build/example && ./build/example