golang


本文摘自网络,作者,侵删。

  1. base64 & aes 加密
    base64.StdEncoding.DecodedLen
    returns the maximum length in bytes of the decoded data 导致密文长度异常解密失败
// base64编码
cipherTextBase64 := make([]byte, base64.StdEncoding.EncodedLen(len(cipherText)))
base64.StdEncoding.Encode(cipherTextBase64, cipherText)

// base64解码
cipherText := make([]byte, base64.StdEncoding.DecodedLen(len(cipherTextWithBase64)))
_, err := base64.StdEncoding.Decode(cipherText, cipherTextWithBase64)

// 如何解决

n, err := base64.StdEncoding.Decode(cipherText, cipherTextWithBase64)
cipherText[:n]

本文来自:简书

感谢作者:见云开

查看原文:golang

相关阅读 >>

Golang如何实现收发邮件?

手撸Golang 行为型设计模式 迭代器模式

Golang pprof 性能分析工具

Go语言闭包谈函数式编程

Golang1.4bootstrap无法直接在aarch64编译

聊聊cortex的readring

Golang defer 特性姿势还是有必要了解下的!!!

重温Golang要点-常量、字符串、类型转换

手撸Golang 行为型设计模式 委派模式

手撸Golang 基本数据结构与算法 栈

更多相关阅读请进入《Go》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...