9

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.

Ahmad
  • 5,551
  • 8
  • 41
  • 57
molleman
  • 2,934
  • 16
  • 61
  • 92
  • 2
    If you cannot understand a tutorial you are not going to understand an even more succinct answer here on SO. Perhaps you can be a little more specific about what you don't understand in all the examples you discovered via the google. – President James K. Polk Feb 25 '11 at 00:28
  • possible duplicate of [Java 256bit AES Encryption](http://stackoverflow.com/questions/992019/java-256bit-aes-encryption) – erickson Jun 27 '11 at 20:40

2 Answers2

12

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.

Dylan Knowles
  • 2,726
  • 1
  • 26
  • 52
-1

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);
        }
Ori Marko
  • 56,308
  • 23
  • 131
  • 233