Standard library / crypto/sha1

crypto/sha1.New()

Create an incremental SHA1 hash. Write accepts successive chunks; Sum appends the digest without consuming the hash state. Cryptographically broken for collision resistance; use only for unavoidable legacy compatibility, never new signatures or adversarial integrity checks. Expected stdout: 'a9993e364706816aba3e25717850c26c9cd0d89d\n'.

Formal Syntax & Structure

go syntaxgo
func New() hash.Hash

Return Value

hash.Hash

Fresh SHA1 hash instance.

Working Example

Example Snippetgo
package main
import (  "crypto/sha1"  "fmt")
func main() {  h := sha1.New()  h.Write([]byte("a"))  h.Write([]byte("bc"))  fmt.Printf("%x\n", h.Sum(nil))}
Go Reference