Generate SHA-1 Hash using Go

crypto/sha1 package

package main

import (
    "crypto/sha1"
    "fmt"
)

func main() {
    text := "Hello"

    hasher := sha1.New()
    hasher.Write([]byte(text))

    rawDigest := hasher.Sum(nil)
    digest := fmt.Sprintf("%x", rawDigest)

    fmt.Println(digest)
}

Leave a Comment

Cancel reply

Your email address will not be published.