The MD5 of Golang Signature Series

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed.

first, from a simple point, It 's also used to compare multiple MD5 encryption to start, not much to say directly on the code

Package Signimport ' crypto/md5 ' type md5client struct {}var MD5 = Md5client{}func (this *md5client) Encrypt (Plantext []byte ) []byte {result: = MD5. Sum (Plantext) return result[:]}/* to the information to be encrypted add salt */func (this *md5client) Encryptwithsalt (Plantext []byte,salt []byte] []byt] e {hash: = MD5. New () hash. Write (Plantext) hash. Write (salt) return hash. Sum (Nil)}

For the definition of salt, please poke here

After the encrypted 16-bit byte array, if you want to turn into a string, you can use the 16 character set for transcoding, the code is as follows

Func Main () {sum:=sign. MD5. Encrypt ([]byte (' Sweet Potato duck ')] sumstr:=hex. Encodetostring (SUM)}

Ok,md5 to the end, simple, next we talk about AES ...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.