add crypto sha1, sha256, sha512

This commit is contained in:
tsingbx
2024-07-31 13:56:42 +08:00
parent 36072584d0
commit 2d7958f726
9 changed files with 310 additions and 0 deletions

11
_cmptest/sha1demo/sha1.go Normal file
View File

@@ -0,0 +1,11 @@
package main
import (
"crypto/sha1"
"fmt"
)
func main() {
data := []byte("This page intentionally left blank.")
fmt.Printf("% x", sha1.Sum(data))
}

View File

@@ -0,0 +1,11 @@
package main
import (
"crypto/sha256"
"fmt"
)
func main() {
sum := sha256.Sum256([]byte("hello world\n"))
fmt.Printf("%x", sum)
}

View File

@@ -0,0 +1,11 @@
package main
import (
"crypto/sha512"
"fmt"
)
func main() {
sum := sha512.Sum512([]byte("hello world\n"))
fmt.Printf("%x", sum)
}