github.com/mdempsky/go@v0.0.0-20151201204031-5dd372bd1e70/src/crypto/md5/example_test.go (about)

     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  
     5  package md5_test
     6  
     7  import (
     8  	"crypto/md5"
     9  	"fmt"
    10  	"io"
    11  )
    12  
    13  func ExampleNew() {
    14  	h := md5.New()
    15  	io.WriteString(h, "The fog is getting thicker!")
    16  	io.WriteString(h, "And Leon's getting laaarger!")
    17  	fmt.Printf("%x", h.Sum(nil))
    18  	// Output: e2c569be17396eca2a2e3c11578123ed
    19  }
    20  
    21  func ExampleSum() {
    22  	data := []byte("These pretzels are making me thirsty.")
    23  	fmt.Printf("%x", md5.Sum(data))
    24  	// Output: b0804ec967f48520697662a204f5fe72
    25  }