sha256-hashes

sha256 hashes

原文:https://gobyexample.com/sha256-hashes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
package main

import (
	"crypto/sha256"
	"fmt"
)

func main() {
	s := "sha256 this string"

	h := sha256.New()

	h.Write([]byte(s))

	bs := h.Sum(nil)

	fmt.Println(s)         // sha256 this string
	fmt.Printf("%x\n", bs) // 1af1dfa857bf1d8814fe1af8983c18080019922e557f15a8a0d3db739d77aacb
}
最后修改 October 10, 2024: 更新 (a4b8f85)