Thursday, February 29, 2024
HomeSoftware EngineeringLearn how to SHA256 a String in Golang

Learn how to SHA256 a String in Golang


If it’s essential to SHA256 a String in Go, then you should use the crypto/sha256 package deal.

SHA256 a String in Go

package deal most important

import (
	"crypto/sha256"
	"fmt"
)

func most important() {
	s := "A pattern string to SHA256!"

	h := sha256.New()

	h.Write([]byte(s))

	bs := h.Sum(nil)

	fmt.Println(s)
	fmt.Printf("%xn", bs)
}

The output will seem like this:

A pattern string to SHA256!
9abf637c7e39cc4ef84d6d92cf7ffe168dc922b8ae666260d907e0353865ce89
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments