标签:pac string dba lan hash package nil sum md5加密
package main import ( "fmt" "hash/crc64" ) func main(){ s:="打死udhanckhdkja" //先创建一个table table := crc64.MakeTable(crc64.ECMA) //传入字节切片和table,返回一个uint64 fmt.Println(crc64.Checksum([]byte(s), table)) //4295263180068867775 }
package main import ( "crypto/md5" "encoding/hex" "fmt" ) func main(){ //方法一: s:="udhanckhdkja" //返回字节切片,长度为16 res := md5.Sum([]byte(s)) //注意此时不可以使用string(res)来转化,会得到乱码 //要使用hex.EncodeToString,但是要传入切片 fmt.Println(hex.EncodeToString(res[:]))//538a7e42c664f84d1dba984976489311 //方法二: md5ctx := md5.New() md5ctx.Write([]byte(s)) res1 := md5.Sum(nil) fmt.Println(hex.EncodeToString(res1[:]))//d41d8cd98f00b204e9800998ecf8427e }
标签:pac string dba lan hash package nil sum md5加密
原文地址:https://www.cnblogs.com/traditional/p/10082288.html