crypto.sha512 #
Copyright (c) 2019-2024 Alexander Medvednikov. All rights reserved. Use of this source code is governed by an MIT license that can be found in the LICENSE file. Package sha512 implements the SHA-384, SHA-512, SHA-512/224, and SHA-512/256 hash algorithms as defined in FIPS 180-4. Based off: https://github.com/golang/go/tree/master/src/crypto/sha512 Last commit: https://github.com/golang/go/commit/3ce865d7a0b88714cc433454ae2370a105210c01
Constants #
const size = 64
size is the size, in bytes, of a SHA-512 checksum.
const size224 = 28
size224 is the size, in bytes, of a SHA-512/224 checksum.
const size256 = 32
size256 is the size, in bytes, of a SHA-512/256 checksum.
const size384 = 48
size384 is the size, in bytes, of a SHA-384 checksum.
const block_size = 128
block_size is the block size, in bytes, of the SHA-512/224, SHA-512/256, SHA-384 and SHA-512 hash functions.
fn hexhash #
fn hexhash(s string) string
hexhash returns a hexadecimal SHA512 hash sum string of s.
fn hexhash_384 #
fn hexhash_384(s string) string
hexhash_384 returns a hexadecimal SHA384 hash sum string of s.
fn hexhash_512_224 #
fn hexhash_512_224(s string) string
hexhash_512_224 returns a hexadecimal SHA512/224 hash sum string of s.
fn hexhash_512_256 #
fn hexhash_512_256(s string) string
hexhash_512_256 returns a hexadecimal 512/256 hash sum string of s.
fn new #
fn new() &Digest
new returns a new Digest (implementing hash.Hash) computing the SHA-512 checksum.
fn new384 #
fn new384() &Digest
new384 returns a new Digest (implementing hash.Hash) computing the SHA-384 checksum.
fn new512_224 #
fn new512_224() &Digest
new512_224 returns a new Digest (implementing hash.Hash) computing the SHA-512/224 checksum.
fn new512_256 #
fn new512_256() &Digest
new512_256 returns a new Digest (implementing hash.Hash) computing the SHA-512/256 checksum.
fn sum384 #
fn sum384(data []u8) []u8
sum384 returns the SHA384 checksum of the data.
fn sum512 #
fn sum512(data []u8) []u8
sum512 returns the SHA512 checksum of the data.
fn sum512_224 #
fn sum512_224(data []u8) []u8
sum512_224 returns the Sum512/224 checksum of the data.
fn sum512_256 #
fn sum512_256(data []u8) []u8
sum512_256 returns the Sum512/256 checksum of the data.
fn (Digest) free #
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) copy_from #
fn (mut d Digest) copy_from(src &Digest)
copy_from overwrites the state of d with the state of src, without allocating. Afterwards d computes the same kind of checksum (SHA-512, SHA-384, SHA-512/224 or SHA-512/256) as src, and continues from the data that was written to src so far.
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 SHA512 or SHA384 checksum of digest with the data bytes in b_in
fn (Digest) checksum_into #
fn (mut d Digest) checksum_into(mut out []u8)
checksum_into finalizes d and writes its checksum into the first d.size() bytes of out, without allocating. It panics if out is shorter than d.size(). Like sum512, it consumes the state of d: call reset() or copy_from() before writing to d again.
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.