mirror of
https://github.com/gopl-zh/gopl-zh.github.com.git
synced 2025-09-12 22:52:05 +00:00
good good study, day day up!
This commit is contained in:
25
vendor/gopl.io/ch4/sha256/main.go
generated
vendored
Normal file
25
vendor/gopl.io/ch4/sha256/main.go
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
// Copyright © 2016 Alan A. A. Donovan & Brian W. Kernighan.
|
||||
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
|
||||
|
||||
// See page 83.
|
||||
|
||||
// The sha256 command computes the SHA256 hash (an array) of a string.
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
//!+
|
||||
import "crypto/sha256"
|
||||
|
||||
func main() {
|
||||
c1 := sha256.Sum256([]byte("x"))
|
||||
c2 := sha256.Sum256([]byte("X"))
|
||||
fmt.Printf("%x\n%x\n%t\n%T\n", c1, c2, c1 == c2, c1)
|
||||
// Output:
|
||||
// 2d711642b726b04401627ca9fbac32f5c8530fb1903cc4db02258717921a4881
|
||||
// 4b68ab3847feda7d6c62c1fbcbeebfa35eab7351ed5e78f4ddadea5df64b8015
|
||||
// false
|
||||
// [32]uint8
|
||||
}
|
||||
|
||||
//!-
|
Reference in New Issue
Block a user