AES加密字符串的最大长度只能8位吗?

jlcanoe jlcanoe 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
用AES加密字符串,再解密后,解密出的字符串只有最初字符串的前8位了,8位以后的字符都丢掉了,请问是怎么回事?比如我要加密"1234567890",再解密后,只剩下"12345678"了。是不是类本身的限制,还是我代码里面限制了?以下是我的代码。

public string AESEncrypt (AES.KeySize keySize, string Input)
{
byte[] input = new byte[16];
byte[] output = new byte[16];
AES aes = new AES (keySize, new byte[16]);
input = Encoding.Unicode.GetBytes (Input.PadRight (8, ' '));
aes.Cipher (input, output);
return Encoding.Unicode.GetString (output);
}

public string AESDecode(AES.KeySize keySize,string Input)
{
byte[] input = new byte[16];
byte[] output = new byte[16];
input = Encoding.Unicode.GetBytes(Input);
AES aes = new AES(keySize,new byte[16]);
aes.InvCipher(input,output);
return Encoding.Unicode.GetString(output);
}

//点击按钮加密
private void Button1_Click(object sender, System.EventArgs e)
{
Label1.Text = AESEncrypt(Namespace.AES.KeySize.Bits256 ,TextBox1.Text);
}

//点击按钮解密
private void Button2_Click(object sender, System.EventArgs e)
{
Label2.Text = AESDecode(Namespace.AES.KeySize.Bits256, AESEncrypt(Namespace.AES.KeySize.Bits256 ,TextBox1.Text));
}
...全文

相关推荐

评论 2
收藏 已收藏
分享
返回顶部
jlcanoe
.NET社区 62,272 成员 668,968 内容