add openssl sha1,sha256,sha512

This commit is contained in:
tsingbx
2024-07-30 18:32:27 +08:00
parent bdca09007d
commit cd32d6debe
6 changed files with 337 additions and 0 deletions

29
_demo/cshademo/sha.go Normal file
View File

@@ -0,0 +1,29 @@
package main
import (
"fmt"
"unsafe"
"github.com/goplus/llgo/c/openssl"
)
func main() {
var sha1 openssl.SHA_CTX
sha1.Init()
sha1.UpdateString("His money is twice tainted:")
sha1.UpdateString(" 'taint yours and 'taint mine.")
h := make([]byte, openssl.SHA_DIGEST_LENGTH)
sha1.Final(unsafe.SliceData(h))
fmt.Printf("%x\n", h)
var sha256 openssl.SHA256_CTX
sha256.Init()
sha256.UpdateString("His money is twice tainted:")
sha256.UpdateString(" 'taint yours and 'taint mine.")
hh := make([]byte, openssl.SHA256_DIGEST_LENGTH)
sha256.Final(unsafe.SliceData(hh))
fmt.Printf("%x\n", hh)
}