From 57e850e932bca8d4683be8019e0ab9aee0177725 Mon Sep 17 00:00:00 2001 From: blackshirt Date: Mon, 14 Feb 2022 05:10:50 +0700 Subject: [PATCH] crypto.sha512, crypto.sha256 : Make public the `write()` and `sum()` methods (#13461) --- vlib/crypto/sha256/sha256.v | 2 +- vlib/crypto/sha512/sha512.v | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/vlib/crypto/sha256/sha256.v b/vlib/crypto/sha256/sha256.v index 07e28c0716..e5d391986f 100644 --- a/vlib/crypto/sha256/sha256.v +++ b/vlib/crypto/sha256/sha256.v @@ -90,7 +90,7 @@ pub fn new224() &Digest { } // write writes the contents of `p_` to the internal hash representation. -fn (mut d Digest) write(p_ []byte) ?int { +pub fn (mut d Digest) write(p_ []byte) ?int { unsafe { mut p := p_ nn := p.len diff --git a/vlib/crypto/sha512/sha512.v b/vlib/crypto/sha512/sha512.v index da71712c74..a13c7fa65a 100644 --- a/vlib/crypto/sha512/sha512.v +++ b/vlib/crypto/sha512/sha512.v @@ -149,7 +149,7 @@ fn new384() &Digest { } // write writes the contents of `p_` to the internal hash representation. -fn (mut d Digest) write(p_ []byte) ?int { +pub fn (mut d Digest) write(p_ []byte) ?int { unsafe { mut p := p_ nn := p.len @@ -183,7 +183,8 @@ fn (mut d Digest) write(p_ []byte) ?int { } } -fn (d &Digest) sum(b_in []byte) []byte { +// sum returns the SHA512 or SHA384 checksum of digest with the data bytes in `b_in` +pub fn (d &Digest) sum(b_in []byte) []byte { // Make a copy of d so that caller can keep writing and summing. mut d0 := *d hash := d0.checksum()