Commit c687be42 authored by Rob Pike's avatar Rob Pike

crypto/md5,sha1: add examples for Sum

LGTM=dave
R=golang-codereviews, dave
CC=golang-codereviews
https://golang.org/cl/66900044
parent cd13a57b
...@@ -17,3 +17,9 @@ func ExampleNew() { ...@@ -17,3 +17,9 @@ func ExampleNew() {
fmt.Printf("%x", h.Sum(nil)) fmt.Printf("%x", h.Sum(nil))
// Output: e2c569be17396eca2a2e3c11578123ed // Output: e2c569be17396eca2a2e3c11578123ed
} }
func ExampleSum() {
data := []byte("These pretzels are making me thirsty.")
fmt.Printf("%x", md5.Sum(data))
// Output: b0804ec967f48520697662a204f5fe72
}
...@@ -12,7 +12,14 @@ import ( ...@@ -12,7 +12,14 @@ import (
func ExampleNew() { func ExampleNew() {
h := sha1.New() h := sha1.New()
io.WriteString(h, "His money is twice tainted: 'taint yours and 'taint mine.") io.WriteString(h, "His money is twice tainted:")
io.WriteString(h, " 'taint yours and 'taint mine.")
fmt.Printf("% x", h.Sum(nil)) fmt.Printf("% x", h.Sum(nil))
// Output: 59 7f 6a 54 00 10 f9 4c 15 d7 18 06 a9 9a 2c 87 10 e7 47 bd // Output: 59 7f 6a 54 00 10 f9 4c 15 d7 18 06 a9 9a 2c 87 10 e7 47 bd
} }
func ExampleSum() {
data := []byte("This page intentionally left blank.")
fmt.Printf("% x", sha1.Sum(data))
// Output: af 06 49 23 bb f2 30 15 96 aa c4 c2 73 ba 32 17 8e bc 4a 96
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment