crypto.sha3 #
Constants #
const size_224 = 28
size_224 is the size, in bytes, of a sha3 sum224 checksum.
const size_256 = 32
size_256 is the size, in bytes, of a sha3 sum256 checksum.
const size_384 = 48
size_384 is the size, in bytes, of a sha3 sum384 checksum.
const size_512 = 64
size_512 is the size, in bytes, of a sha3 sum512 checksum.
const rate_224 = 144
rate_224 is the rate, in bytes, absorbed into the sponge on every permutation
const rate_256 = 136
rate_256 is the rate, in bytes, absorbed into the sponge on every permutation
const rate_384 = 104
rate_384 is the rate, in bytes, absorbed into the sponge on every permutation
const rate_512 = 72
rate_512 is the rate, in bytes, absorbed into the sponge on every permutation
const xof_rate_128 = 168
xof_rate_128 is the capacity, in bytes, of a 128 bit extended output function sponge
const xof_rate_256 = 136
xof_rate_256 is the capacity, in bytes, of a 256 bit extended output function sponge
fn keccak256 #
fn keccak256(data []u8) []u8
keccak256 returns the keccak 256 bit checksum of the data.
fn keccak512 #
fn keccak512(data []u8) []u8
keccak512 returns the keccak 512 bit checksum of the data.
fn new128xof #
fn new128xof(output_len int) !&Digest
new128_xof initializes the digest structure for a sha3 128 bit extended output function
fn new224 #
fn new224() !&Digest
new224 initializes the digest structure for a sha3 224 bit hash
fn new256 #
fn new256() !&Digest
new256 initializes the digest structure for a sha3 256 bit hash
fn new256keccak #
fn new256keccak() !&Digest
new256keccak initializes the digest structure for a keccak 256 bit hash
fn new256xof #
fn new256xof(output_len int) !&Digest
new256_xof initializes the digest structure for a sha3 256 bit extended output function
fn new384 #
fn new384() !&Digest
new384 initializes the digest structure for a sha3 384 bit hash
fn new512 #
fn new512() !&Digest
new512 initializes the digest structure for a sha3 512 bit hash
fn new512keccak #
fn new512keccak() !&Digest
new512keccak initializes the digest structure for a keccak 512 bit hash
fn new_digest #
fn new_digest(absorption_rate int, hash_size int, config PaddingConfig) !&Digest
new_digest creates an initialized digest structure based on the hash size.
absorption_rate is the number of bytes to be absorbed into the sponge per permutation.
hash_size - the number if bytes in the generated hash. Legal values are 224, 256, 384, and 512.
config - the padding setting for hash generation. .sha3 should be used for FIPS PUB 202 compliant SHA3-224, SHA3-256, SHA3-384 and SHA3-512. Use .keccak if you want a legacy Keccak-224, Keccak-256, Keccak-384 or Keccak-512 algorithm. .xof is for extended output functions.
fn new_xof_digest #
fn new_xof_digest(absorption_rate int, hash_size int) !&Digest
new_xof_digest creates an initialized digest structure based on the absorption rate and how many bytes of output you need
absorption_rate is the number of bytes to be absorbed into the sponge per permutation. Legal values are xof_rate_128 and xof_rate_256.
hash_size - the number if bytes in the generated hash. Legal values are positive integers.
fn shake128 #
fn shake128(data []u8, output_len int) []u8
shake128 returns the sha3 shake128 bit extended output
fn shake256 #
fn shake256(data []u8, output_len int) []u8
shake256 returns the sha3 shake256 bit extended output
fn sum224 #
fn sum224(data []u8) []u8
sum224 returns the sha3 224 bit checksum of the data.
fn sum256 #
fn sum256(data []u8) []u8
sum256 returns the sha3 256 bit checksum of the data.
fn sum384 #
fn sum384(data []u8) []u8
sum384 returns the sha3 384 bit checksum of the data.
fn sum512 #
fn sum512(data []u8) []u8
sum512 returns the sha3 512 bit checksum of the data.
fn (Digest) write #
fn (mut d Digest) write(data []u8) !
write adds bytes to the sponge.
This is the absorption phase of the computation.
fn (Digest) checksum #
fn (mut d Digest) checksum() []u8
checksum finalizes the hash and returns the generated bytes.
enum Padding #
enum Padding as u8 {
keccak = 0x01
sha3 = 0x06
xof = 0x1f
}
the low order pad bits for a hash function
struct PaddingConfig #
struct PaddingConfig {
pub:
padding Padding = .sha3
}