Share & grow the world's code base!

Delve into a community where programmers unite to discover code snippets, exchange skills, and enhance their programming proficiency. With abundant resources and a supportive community, you'll find everything essential for your growth and success.

1 snippets
  • SHA256 hashes in Go

    package main
    import (
    func main() {
        str := "some string to calculate hash"
        hash := sha256.New()
        sum := hash.Sum(nil) // the argument can be used to append to an existing byte slice
        fmt.Printf("%x\n", sum)
    // go run main.go 
    // some string to calculate hash
    // 7aad383b9ad516fa67057adc283ce2cf71858aff317a5e267adebfdbd5dda5fd

    SHA256 hashes are commonly used to generate short identifiers for binary or text data. This example shows how to calculate SHA256 hashes for string in Go.