How to encrypt data using AES in Java

2020-06-16 03:24发布

I wish to encrypt a piece of data using AES (cbc) in java , I Want to use my own IV, which I have held in a byte array and my own key held in a byte array.

How would I go about doing this?

I'm searching for it to find tutorials on this topic.

2条回答
啃猪蹄的小仙女
2楼-- · 2020-06-16 04:14

This is probably the best guide that I've found on the subject. It explains the basics, one concept at a time, in simple terms.

查看更多
神经病院院长
3楼-- · 2020-06-16 04:23

Formally it encrypts the string into unreadable format. Use same code to decrypt.

ENCRYPT:

    String s1="arshad";

    char[] s2=s1.toCharArray();
    int s3= s2.length;
    System.out.println(s3);
   int i=0;
   // for(int j=0;j<s3;j++)
          //  System.out.println(s2[j]);

       for(i=0;i<((s3)/2);i++)
        {
            char z,f=10;
            z=(char) (s2[i] * f);
            s2[i]=s2[(s3-1)-i];
            s2[(s3-1)-i]=z;
            String b=new String(s2);
            print(b);
        }
查看更多
登录 后发表回答