In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article shows you how to encrypt and decrypt AES, DES and 3DES in Golang. The content is concise and easy to understand, which will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.
Functional wrapper of the Openssl encryption:OpenSSL library for symmetric and asymmetric encryption and decryption.
Install go get-u github.com/thinkoner/openssl usage AES
The length of the key can be 16-24-32 characters (128 ram 192 ram 256 bits).
AES-ECB:
Src: = byte ("123456") key: = [] byte ("1234567890123456") dst, _: = openssl.AesECBEncrypt (src, key, openssl.PKCS7_PADDING) fmt.Printf (base64.StdEncoding.EncodeToString (dst)) / / yXVUkR45PFz0UfpbDB8/ew==dst, _ = openssl.AesECBDecrypt (dst, key, openssl.PKCS7_PADDING) fmt.Println (string (dst)) / / 123456
AES-CBC:
Src: = byte ("123456") key: = [] byte ("1234567890123456") iv: = [] byte ("1234567890123456") dst, _: = openssl.AesCBCEncrypt (src, key, iv, openssl.PKCS7_PADDING) fmt.Println (base64.StdEncoding.EncodeToString (dst)) / / 1jdzWuniG6UMtoa3T6uNLA==dst, _ = openssl.AesCBCDecrypt (dst, key, iv, openssl.PKCS7_PADDING) fmt.Println (string (dst)) / / 123456DES
The key must be 8 characters (64 bits) long.
DES-ECB:
Openssl.DesECBEncrypt (src, key, openssl.PKCS7_PADDING) openssl.DesECBDecrypt (src, key, openssl.PKCS7_PADDING)
DES-CBC:
Openssl.DesCBCEncrypt (src, key, iv, openssl.PKCS7_PADDING) openssl.DesCBCDecrypt (src, key, iv, openssl.PKCS7_PADDING) 3DES
The length of the key must be 24 characters (192 bits).
3DES-ECB:
Openssl.Des3ECBEncrypt (src, key, openssl.PKCS7_PADDING) openssl.Des3ECBDecrypt (src, key, openssl.PKCS7_PADDING)
3DES-CBC:
Openssl.Des3CBCEncrypt (src, key, iv, openssl.PKCS7_PADDING) openssl.Des3CBCDecrypt (src, key, iv, openssl.PKCS7_PADDING) the above content is what AES, DES, 3DES encryption and decryption are like in Golang. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.