mirror of
https://github.com/gopl-zh/gopl-zh.github.com.git
synced 2025-12-20 12:44:20 +08:00
ch4: fix code path
This commit is contained in:
@@ -80,9 +80,8 @@ fmt.Println(a == d) // compile error: cannot compare [2]int == [3]int
|
||||
|
||||
作爲一個眞實的例子,crypto/sha256包的Sum256函數對一個任意的字節slice類型的數據生成一個對應的消息摘要。消息摘要有256bit大小,因此對應[32]byte數組類型。如果兩個消息摘要是相同的,那麽可以認爲兩個消息本身也是相同(譯註:理論上有HASH碼碰撞的情況,但是實際應用可以基本忽略);如果消息摘要不同,那麽消息本身必然也是不同的。下面的例子用SHA256算法分别生成“x”和“X”兩個信息的摘要:
|
||||
|
||||
<u><i>gopl.io/ch4/sha256</i></u>
|
||||
```Go
|
||||
gopl.io/ch4/sha256
|
||||
|
||||
import "crypto/sha256"
|
||||
|
||||
func main() {
|
||||
|
||||
Reference in New Issue
Block a user