AES算法:C#转JAVA

VilenZYP 2012-08-24 10:43:45

public static byte[] AESEncrypt(string plainText, string strKey)
{
byte[] cipherBytes2 = new byte[16];
byte[] cipherBytes0 = new byte[32];
byte[] cipherBytes1 = new byte[16];
string strS = plainText.Substring(0, 16);
string strL = plainText.Substring(16, 16);
byte[] inputByteArray = Encoding.UTF8.GetBytes(strS);//得到需要加密的字节数组
byte[] inputByteArray1 = Encoding.UTF8.GetBytes(strL);//得到需要加密的字节数组
byte[] keyBytes = Encoding.UTF8.GetBytes(strKey);
Aes a = new Aes(Aes.KeySize.Bits128, keyBytes);
a.Cipher(inputByteArray, cipherBytes1);
a.Cipher(inputByteArray1, cipherBytes2);
Array.Copy(cipherBytes1, 0, cipherBytes0, 0, cipherBytes1.Length);
Array.Copy(cipherBytes2, 0, cipherBytes0, cipherBytes1.Length,
cipherBytes2.Length);
return cipherBytes0;
}


将上述C#的AES算法改写成JAVA...
...全文
99 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
VilenZYP 2012-08-24
  • 打赏
  • 举报
回复
没人么?

50,530

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧