SHA1 Hashes _ golang

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 ; ...

本文来自:博客园

感谢作者:jackkiexu

查看原文:SHA1 Hashes _ golang

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。