SHA1 hashes are frequently used to compute short identities for binary or text blobs. For example, the git revision control system uses SHA1 extensively to identify versioned files and directories. Here's how to compute SHA1 hashes in Go
package main import ( "crypto/sha1" "fmt" ) func main() { s := "sha1 this string" h := sha1.New() h.Write([]byte(s)) bs := h.Sum(nil) fmt.Println(s) fmt.Println("%x\n", bs) }
sha1 this string %x [207 35 223 34 7 217 154 116 251 225 105 227 235 160 53 230 51 182 93 148]
总结 :
1 ; ...
有疑问加站长微信联系(非本文作者)