go标准库的学习-crypto/sha256
参考:https://studygolang.com/pkgdoc 导入方式: import " crypto/sha256 " sha256包实现了SHA224和SHA256哈希算法,参见FIPS 180-4。 Constants const BlockSize = 64 SHA224和SHA256的字节块大小。 const Size = 32 SHA256校验和的字节长度。 const Size224 = 28 SHA224校验和的字节长度。 func Sum256 func Sum256(data [] byte ) [Size] byte 返回数据的SHA256校验和。 举例: package main import ( " fmt " " crypto/sha256 " ) func main() { sum : = sha256.Sum256([] byte ( " hello world\n " )) fmt.Printf( " %x\n " , sum) // a948904f2f0f479b8f8197694b30184b0d2ed1c1cd2a1ec0fb85d299a192a447 } func New func New() hash.Hash 返回一个新的使用SHA256校验算法的hash.Hash接口。 可见 go标准库的学习-hash 举例: