Sha256

概述 #

调用 crypto/sha256 包即可。

例子 #

package main

import (
	"crypto/sha256"
	"fmt"
)

func main() {
	s := "hello world"
	h := sha256.New()
	h.Write([]byte(s))
	res := h.Sum(nil)
	fmt.Printf("sha245(`hello world`) = %x\n", res)
}

// $ go run main.go
// 输出如下
/**
  sha256(`hello world`) = b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9
*/

转载申请

本作品采用 知识共享署名 4.0 国际许可协议 进行许可,转载时请注明原文链接,图片在使用时请保留全部内容,商业转载请联系作者获得授权。

© 蛮荆 | 陕公网安备 61011302001681 号 | 陕ICP备2023004378号-1 | Rendered by Hugo