Standard library / crypto/sha256

crypto/sha256.Sum256()

Compute the SHA256 digest of a complete byte slice. 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 Sum256(data []byte) [Size]byte

Parameters & Attributes

NameTypeDescription
data[]byteExact input bytes to hash.

Return Value

[Size]byte

Fixed-size SHA256 digest.

Working Example

Example Snippetgo
package main
import (  "crypto/sha256"  "fmt")
func main() { fmt.Printf("%x\n", sha256.Sum256([]byte("abc"))) }
Go Reference