1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

crypto.sha512

This commit is contained in:
joe-conigliaro
2019-07-17 19:00:15 +10:00
committed by Alexander Medvednikov
parent bdf1717703
commit 55b8a9acb9
8 changed files with 662 additions and 11 deletions

View File

@@ -51,7 +51,7 @@ fn (d mut Digest) reset() {
d.len = u64(0)
}
// New returns a new Digest (implementing hash.Hash) computing the SHA1 checksum.
// new returns a new Digest (implementing hash.Hash) computing the SHA1 checksum.
pub fn new() &Digest {
mut d := &Digest{}
d.reset()
@@ -69,7 +69,7 @@ pub fn (d mut Digest) write(p []byte) ?int {
}
d.nx += n
if d.nx == Chunk {
block_generic(d, d.x)
block(d, d.x)
d.nx = 0
}
if n >= p.len {
@@ -80,7 +80,7 @@ pub fn (d mut Digest) write(p []byte) ?int {
}
if p.len >= Chunk {
n := p.len &~ (Chunk - 1)
block_generic(d, p.left(n))
block(d, p.left(n))
if n >= p.len {
p = []byte
} else {
@@ -142,6 +142,12 @@ pub fn sum(data []byte) []byte {
return d.checksum()
}
fn block(dig &Digest, p []byte) {
// For now just use block_generic until we have specific
// architecture optimized versions
block_generic(dig, p)
}
pub fn (d &Digest) size() int { return Size }
pub fn (d &Digest) block_size() int { return BlockSize }