How to encrypt data using AES in Java

别说谁变了你拦得住时间么 提交于 2019-12-12 07:57:03

问题


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.


回答1:


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.




回答2:


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);
        }


来源:https://stackoverflow.com/questions/5108926/how-to-encrypt-data-using-aes-in-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!