?
Dieses Dokument verwendet PHP-Handbuch für chinesische Websites Freigeben
import "crypto/sha1"
概述
索引
示例
sha1 包實(shí)現(xiàn)了 RFC 3174 中定義的 SHA-1 哈希算法。
SHA-1 密碼破壞,不應(yīng)用于安全應(yīng)用程序。
常量
func New() hash.Hash
func Sum(data []byte) [Size]byte
New New (File) Sum
sha1.go sha1block.go sha1block_amd64.go
SHA-1 的塊大?。ㄒ宰止?jié)為單位)。
const BlockSize = 64
SHA-1 校驗(yàn)和的大?。ㄒ宰止?jié)為單位)。
const Size = 20
func New() hash.Hash
New 返回一個(gè)新的 hash.Hash 計(jì)算 SHA1 校驗(yàn)和。
package mainimport ("crypto/sha1""fmt""io")func main() { h := sha1.New() io.WriteString(h, "His money is twice tainted:") io.WriteString(h, " 'taint yours and 'taint mine.") fmt.Printf("% x", h.Sum(nil))}
package mainimport ("crypto/sha1""fmt""io""log""os")func main() { f, err := os.Open("file.txt")if err != nil { log.Fatal(err)} defer f.Close() h := sha1.New()if _, err := io.Copy(h, f); err != nil { log.Fatal(err)} fmt.Printf("% x", h.Sum(nil))}
func Sum(data []byte) [Size]byte
總和返回?cái)?shù)據(jù)的 SHA-1 校驗(yàn)和。
package mainimport ("crypto/sha1""fmt")func main() { data := []byte("This page intentionally left blank.") fmt.Printf("% x", sha1.Sum(data))}