With the following code the input string is* different from output*
*
*
I'm sorry for the mistake.

On Monday, November 19, 2012 6:45:47 PM UTC+1, Antonino wrote:
>
> Hi all,
> I am trying a very simple function to encrypt and decrypt a string.
> With the following code the input string is different.
> Someone could help me?
> The code is not secure but it is not very important at the moment.
>
> String stringKey = "74dc6b9ec2bc29a5490744716e4a7a27";
> String message = "FC:A1:3E:2A:79:B2";
>
> SecretKeySpec sks;
>
> Cipher c,d;
> try {
> sks = new SecretKeySpec(stringKey.getBytes("UTF-8"),"AES");
> c = Cipher.getInstance("AES/ECB/ZeroBytePadding");
> c.init(Cipher.ENCRYPT_MODE, sks);
> c.update(message.getBytes("UTF-8"));
> byte[] ciphertext = c.doFinal();
> Log.i("CE","crypted text: "+ Base64.encodeToString(ciphertext, 
> Base64.DEFAULT));
>  //Decrypt block
> d = Cipher.getInstance("AES/ECB/ZeroBytePadding");
> d.init(Cipher.DECRYPT_MODE, sks);
>  d.update(ciphertext);
> byte[] deCiphertext =d.doFinal();
>
> Log.i("CE","decrypted text: "+ new String(deCiphertext,"UTF-8"));
> } catch ....
>
> Thanks a lot
>

-- 
You received this message because you are subscribed to the Google Groups 
"Android Security Discussions" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/android-security-discuss/-/H8Fmopsi9bsJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/android-security-discuss?hl=en.

Reply via email to