example_test.go 589 B

1234567891011121314151617181920212223242526
  1. // Copyright 2013 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package md5_test
  5. import (
  6. "crypto/md5"
  7. "fmt"
  8. "io"
  9. )
  10. func ExampleNew() {
  11. h := md5.New()
  12. io.WriteString(h, "The fog is getting thicker!")
  13. io.WriteString(h, "And Leon's getting laaarger!")
  14. fmt.Printf("%x", h.Sum(nil))
  15. // Output: e2c569be17396eca2a2e3c11578123ed
  16. }
  17. func ExampleSum() {
  18. data := []byte("These pretzels are making me thirsty.")
  19. fmt.Printf("%x", md5.Sum(data))
  20. // Output: b0804ec967f48520697662a204f5fe72
  21. }