Get the App
SLTechnology News&Howtos  ›  Development  › 

What is the method of SHA1 hashing of strings in Go language

Shulou Source: shulou.com Published: 2022-06-03 11:55:04 10月19日 Update

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.

Tags: Characters strings hashes codes methods languages operations content more help good interests guys buddies articles knowledge articles results references output Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno Shulou Technology Xiaomi Linux Apple