[GO] 解决:crypto/aes: invalid key size 14
2023-02-18 15:41:32 时间
当使用AES加解密的时候报了这个错误
原因是AES的key字节长度不对
看源码
// NewCipher creates and returns a new cipher.Block. // The key argument should be the AES key, // either 16, 24, or 32 bytes to select // AES-128, AES-192, or AES-256. func NewCipher(key []byte) (cipher.Block, error) { k := len(key) switch k { default: return nil, KeySizeError(k) case 16, 24, 32: break } return newCipher(key) }
只允许16、24、32字节长度
所以把key设置成16字节长度就ok了,英文等字符,一个字符一个字节
相关文章
- PHP 拼手气红包分配算法
- git rm 从暂存区中删除内容
- git checkout 命令详解
- git add 命令详解
- git status 查看仓库文件状态
- git commit 命令详解
- PHP 获取手机号运营商
- git init 初始化仓库
- Linux NTP工具的基本使用
- Linux 系统环境监测
- Linux I/O模型
- Linux Lvs的防火墙标记
- linux LVS的DR模式多网段
- linux LVS的DR模式实现
- Linux LVS-NAT模式的实现
- linux IPtables的匹配条件
- linux IPtables 规则的管理
- Linux IPtables相关概念
- Linux 使用ipvsadm管理LVS
- Linux LVS的调度算法