Standard library / crypto/sha256
crypto/sha256.New()
Create an incremental SHA256 hash. Write accepts successive chunks; Sum appends the digest without consuming the hash state. A digest alone does not authenticate data; use HMAC or a signature where appropriate. Not a password hashing scheme. Expected stdout: 'ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad\n'.
Formal Syntax & Structure
go syntaxgo
func New() hash.HashReturn Value
hash.Hash
Fresh SHA256 hash instance.
Working Example
Example Snippetgo
package main
import ( "crypto/sha256" "fmt")
func main() { h := sha256.New() h.Write([]byte("a")) h.Write([]byte("bc")) fmt.Printf("%x\n", h.Sum(nil))}