Skip to Main Content

Java Security

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

AES encryption and decrtption

843811Nov 8 2006 — edited Nov 8 2006
hello everyone,
i am doing rmi program, and the data needs to be encryped and sent.

the client side :
int full = System.in.read();
fn = readchar(full);
byte[] fuenc = my_encrypt.blow_enc(fn);
System.out.println(fuenc);
Byte enc = new Byte(new String (fuenc));
System.out.println(Server.auth((char)un1,(char)pw1, pws ,enc));

On Server side:

auth(char uname1, char pw1, String pin2, Byte fuenc) throws RemoteException
{ try{
byte[] decBytes = my_encrypt.blow_dec(fuenc);
System.out.println(new String(decBytes));
}


the encryption and decryption are as follows.
public static byte[] blow_enc (String str)
throws Exception {
byte[]inpBytes = str.getBytes();
blow_key my_encrypt = new blow_key();
SecretKeySpec key = my_encrypt.Key_gen() ;

Cipher cipher = Cipher.getInstance("AES");
cipher.init(Cipher.ENCRYPT_MODE, key);
byte[] encryptionBytes = cipher.doFinal(inpBytes);
return encryptionBytes;
}

public static byte[] blow_dec(Byte inpBytes)
throws Exception {

blow_key my_encrypt = new blow_key();
SecretKeySpec key = my_encrypt.Key_gen() ;

Cipher cipher = Cipher.getInstance("AES");
cipher.init(Cipher.DECRYPT_MODE, key);
byte[] inp = (inpBytes.toString()).getBytes();
byte[] decryptionBytes = cipher.doFinal(inp);
return decryptionBytes;
}


-------------------------------------------------------------------

i am not getting the any output.
pleae help me.

I also did another program,
like returing string from the enc- dec,
but dint get any output,
pleaase help me.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 6 2006
Added on Nov 8 2006
5 comments
163 views