example_test.go 649 B

1234567891011121314151617181920212223242526
  1. // Copyright 2009 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 sha1_test
  5. import (
  6. "crypto/sha1"
  7. "fmt"
  8. "io"
  9. )
  10. func ExampleNew() {
  11. h := sha1.New()
  12. io.WriteString(h, "His money is twice tainted:")
  13. io.WriteString(h, " 'taint yours and 'taint mine.")
  14. fmt.Printf("% x", h.Sum(nil))
  15. // Output: 59 7f 6a 54 00 10 f9 4c 15 d7 18 06 a9 9a 2c 87 10 e7 47 bd
  16. }
  17. func ExampleSum() {
  18. data := []byte("This page intentionally left blank.")
  19. fmt.Printf("% x", sha1.Sum(data))
  20. // Output: af 06 49 23 bb f2 30 15 96 aa c4 c2 73 ba 32 17 8e bc 4a 96
  21. }