library: crypto

This commit is contained in:
xushiwei
2024-07-31 18:59:25 +08:00
parent 27677f86e4
commit 85509c777d
2 changed files with 8 additions and 1 deletions

View File

@@ -304,6 +304,7 @@ Here are the Go packages that can be imported correctly:
* [hash/adler32](https://pkg.go.dev/hash/adler32)
* [hash/crc32](https://pkg.go.dev/hash/crc32) (partially)
* [hash/crc64](https://pkg.go.dev/hash/crc64)
* [crypto](https://pkg.go.dev/crypto)
* [crypto/md5](https://pkg.go.dev/crypto/md5)
* [crypto/sha1](https://pkg.go.dev/crypto/sha1)
* [crypto/sha256](https://pkg.go.dev/crypto/sha256)

View File

@@ -1,6 +1,7 @@
package main
import (
"crypto"
"crypto/md5"
"fmt"
"io"
@@ -10,5 +11,10 @@ func main() {
h := md5.New()
io.WriteString(h, "The fog is getting thicker!")
io.WriteString(h, "And Leon's getting laaarger!")
fmt.Printf("%x", h.Sum(nil))
fmt.Printf("%x\n", h.Sum(nil))
h = crypto.MD5.New()
io.WriteString(h, "The fog is getting thicker!")
io.WriteString(h, "And Leon's getting laaarger!")
fmt.Printf("%x\n", h.Sum(nil))
}