Skip to content

crypto.sha256 #

Constants #

const size = 32

The size of a SHA256 checksum in bytes.

const size224 = 28

The size of a SHA224 checksum in bytes.

const block_size = 64

The blocksize of SHA256 and SHA224 in bytes.

fn hexhash #

fn hexhash(s string) string

hexhash returns a hexadecimal SHA256 hash sum string of s.

Example

assert sha256.hexhash('V') == 'de5a6f78116eca62d7fc5ce159d23ae6b889b365a1739ad2cf36f925a140d0cc'

fn hexhash_224 #

fn hexhash_224(s string) string

hexhash_224 returns a hexadecimal SHA224 hash sum string of s.

fn new #

fn new() &Digest

new returns a new Digest (implementing hash.Hash) computing the SHA256 checksum.

fn new224 #

fn new224() &Digest

new224 returns a new Digest (implementing hash.Hash) computing the SHA224 checksum.

fn sum #

fn sum(data []u8) []u8

sum returns the SHA256 checksum of the bytes in data.

Example

assert sha256.sum('V'.bytes()).len > 0 == true

fn sum224 #

fn sum224(data []u8) []u8

sum224 returns the SHA224 checksum of the data.

fn sum256 #

fn sum256(data []u8) []u8

sum256 returns the SHA256 checksum of the data.

fn (Digest) free #

unsafe
fn (mut d Digest) free()

free the resources taken by the Digest d

fn (Digest) reset #

fn (mut d Digest) reset()

reset the state of the Digest d

fn (Digest) write #

fn (mut d Digest) write(p_ []u8) !int

write writes the contents of p_ to the internal hash representation.

fn (Digest) sum #

fn (d &Digest) sum(b_in []u8) []u8

sum returns the SHA256 or SHA224 checksum of digest with the data.

fn (Digest) checksum #

deprecated: checksum() will be changed to a private method, use sum() instead
deprecated_after: 2024-04-30
fn (mut d Digest) checksum() []u8

checksum returns the current byte checksum of the Digest, it is an internal method and is not recommended because its results are not idempotent.

fn (Digest) size #

fn (d &Digest) size() int

size returns the size of the checksum in bytes.

fn (Digest) block_size #

fn (d &Digest) block_size() int

block_size returns the block size of the checksum in bytes.