crypto: add utility hexhash functions

This commit is contained in:
Delyan Angelov 2019-09-02 20:22:19 +03:00 committed by Alexander Medvednikov
parent bb9eec8696
commit 93716ee944
4 changed files with 20 additions and 8 deletions

View file

@ -78,14 +78,14 @@ fn (d mut Digest) reset() {
}
// new returns a new Digest (implementing hash.Hash) computing the SHA256 checksum.
pub fn new() *Digest {
pub fn new() &Digest {
mut d := &Digest{}
d.reset()
return d
}
// new224 returns a new Digest (implementing hash.Hash) computing the SHA224 checksum.
pub fn new224() *Digest {
pub fn new224() &Digest {
mut d := &Digest{}
d.is224 = true
d.reset()
@ -212,3 +212,6 @@ pub fn (d &Digest) size() int {
}
pub fn (d &Digest) block_size() int { return BlockSize }
pub fn hexhash(s string) string { return sum256(s.bytes()).hex() }
pub fn hexhash_224(s string) string { return sum224(s.bytes()).hex() }