library: crypto/{sha1, sha256, sha512}

This commit is contained in:
xushiwei
2024-07-31 18:55:46 +08:00
parent 16174ca874
commit 27677f86e4
7 changed files with 63 additions and 34 deletions

View File

@@ -1,6 +1,7 @@
package sha512
import (
"hash"
"unsafe"
"github.com/goplus/llgo/c"
@@ -29,3 +30,14 @@ func (d *digest384) Sum(in []byte) []byte {
d.ctx.Final((*byte)(unsafe.Pointer(hash)))
return append(in, hash[:]...)
}
func New384() hash.Hash {
d := new(digest384)
d.ctx.Init()
return d
}
func Sum384(data []byte) (ret [Size384]byte) {
openssl.SHA384Bytes(data, &ret[0])
return
}