What is the method of SHA1 hashing of strings in Go language
This article introduces the method of SHA1 hash operation on strings in Go language. The content is very detailed. Interested friends can use it for reference. I hope it will be helpful to you.
The code is as follows:
Package mainimport ("fmt", "crypto/md5", "crypto/sha1", "io") / / A pair of strings MD5 hash func a (data string) string {t: = md5.New (); io.WriteString (tdepartment data); return fmt.Sprintf ("% x", t.Sum (nil));} / / a pair of strings SHA1 hash func b (data string) string {t: = sha1.New (); io.WriteString (tForce data) Return fmt.Sprintf ("% x", t.Sum (nil));} func main () {var data string = "abc"; fmt.Printf ("MD5:% s\ n", a (data)); fmt.Printf ("SHA1:% s\ n", b (data));}
The output is as follows:
The copy code is as follows:
D:\ workspace\ golang > GetMd5AndSha1.exeMD5: 900150983cd24fb0d6963f7d28e17f72SHA1: a9993e364706816aba3e25717850c26c9cd0d89d on how the Go language SHA1 hashing strings is shared here, I hope the above content can be helpful to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.