小编Som*_*one的帖子

Java相当于C#AES加密

我在C#中有以下代码.它使用AES对称算法对字节数组进行编码.我需要编写相当于此代码的Java.

class Program
{
    static void Main(string[] args)
    {
        string a = "ABCDEFGHIJKLMNOP";
        byte[] bytes = Encoding.ASCII.GetBytes(a);
        byte[] cipher = encode(bytes, "1111111122222222111111112222222211111111222222221111111122222222", "66666666555555556666666655555555");
    }

    private static byte[] encode(byte[] toEncrypt, string sKey, string sIV)
    {
        byte[] IV = new byte[16];
        byte[] key = new byte[32];
        byte[] array = new byte[toEncrypt.Length];
        string s;

        for (int i = 0; i < IV.Length; ++i)
        {
            s = sIV.Substring(i * 2, 2);
            IV[i] = Convert.ToByte(s, 16);
        }

        for (int i = 0; i < key.Length; …
Run Code Online (Sandbox Code Playgroud)

java encryption encoding aes

6
推荐指数
1
解决办法
3140
查看次数

标签 统计

aes ×1

encoding ×1

encryption ×1

java ×1