| // Copyright 2016 The Go Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style |
| // license that can be found in the LICENSE file. |
| sum := sha256.Sum256([]byte("hello world\n")) |
| // Output: a948904f2f0f479b8f8197694b30184b0d2ed1c1cd2a1ec0fb85d299a192a447 |
| h.Write([]byte("hello world\n")) |
| fmt.Printf("%x", h.Sum(nil)) |
| // Output: a948904f2f0f479b8f8197694b30184b0d2ed1c1cd2a1ec0fb85d299a192a447 |
| f, err := os.Open("file.txt") |
| if _, err := io.Copy(h, f); err != nil { |
| fmt.Printf("%x", h.Sum(nil)) |