mirror of
https://github.com/unknwon/the-way-to-go_ZH_CN.git
synced 2025-08-12 02:16:48 +08:00
update book code
This commit is contained in:
20
eBook/exercises/chapter_12/hash_md5.go
Executable file
20
eBook/exercises/chapter_12/hash_md5.go
Executable file
@@ -0,0 +1,20 @@
|
||||
// hash_md5.go
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt";
|
||||
"crypto/md5"
|
||||
"io"
|
||||
)
|
||||
|
||||
func main() {
|
||||
hasher := md5.New()
|
||||
b := []byte{}
|
||||
io.WriteString(hasher, "test")
|
||||
fmt.Printf("Result: %x\n", hasher.Sum(b))
|
||||
fmt.Printf("Result: %d\n", hasher.Sum(b))
|
||||
}
|
||||
/* Output:
|
||||
Result: 098f6bcd4621d373cade4e832627b4f6
|
||||
Result: [9 143 107 205 70 33 211 115 202 222 78 131 38 39 180 246]
|
||||
*/
|
Reference in New Issue
Block a user