Android AES encryption key


David R.

I am developing an android application and I want to use AES-128 for encryption. I use hex for the key and text.

I use this website: http://testprotect.com/appendix/AEScalc , calculate the AES encryption with the following key: "c4dcc3c6ce0acaec4327b6098260b0be", and the text to be encrypted is: "6F4B1B252A5F0C3F2992E1A65E56E5B8" (hex).

So the result from this site gives me "859499d0802de8cc6ba4f208da648a8f" which is what I want to get. http://hpics.li/d89105a

I found some code online, but many use seeds to generate random keys and I want to fix the keys. Actually, I am using the following code, which I think is the code I need, but the result is giving me D/resultdebug: 72adc67b6d11e1c5fb89ddf5faeb0e030686b91f8bfaf6c41335f08955343f87, it is not the same site as I want.

 String text16 = "6F4B1B252A5F0C3F2992E1A65E56E5B8";
    String secret16 = "c4dcc3c6ce0acaec4327b6098260b0be";

    SecretKeySpec sks = new SecretKeySpec(secret16.getBytes(),"AES");
    Cipher c = Cipher.getInstance("AES");

    c.init(Cipher.ENCRYPT_MODE, sks);
    c.update(text16.getBytes());
    byte[] ciphertext = c.doFinal();
    Log.d("resultdebug",new String(Hex.encode(ciphertext), "ASCII"));

Could you please tell me what's wrong, thanks.

Zaff

Instead of converting hex to binary, you get the binary of the character, not the hex-encoded value.

Related


Implementing AES encryption in Android

MSR I found this Java AES encryption on the internet. Can I modify and use this Java code in an Android application? Actually I don't know if it will fit my android device. If it can be used, does it mean that this Java code can be modified? import java.io.Uns

AES encryption test (android)

Sergey 136 I have developed an encryption program for Android that uses a symmetric key to encrypt and decrypt data (AES algorithm). So I was asked to verify that not only does reverse engineering work, but also that the data can be decrypted using only one ke

AES encryption testing (android)

sergey136 I have developed an encryption program for android which is using a symmetric key to both encrypt and decrypt the data (AES algorithm). So I have been asked to verify that not only a reverse engineering is working correctly but also that only one key

Implementing AES encryption in Android

MSR I found this Java AES encryption on the internet. Can I modify and use this Java code in an Android application? Actually I don't know if it will fit my android device. If it can be used, does it mean that this Java code can be modified? import java.io.Uns

AES encryption on Android

Buddha Gabriel I have to encrypt and decrypt text on android device. I found some solutions, but when I encrypt the text again, the result is different. Can anyone tell me why? Here is my code: public class AESDemo { private static final String password

Android Java AES encryption

Bright I'm currently developing an Android app that includes encrypting a string using AES. But for some reason my app doesn't decrypt correctly. I tried to change the Base64 format but couldn't solve it. The code is similar to the Android Cryptography example

Android encryption/decryption using AES

h4rd4r7c0r3: Is there a good example of how to encrypt and decrypt images and other files using AES on Android ? Nacho L.: Warning: this answer contains code you shouldn't use because it's not secure (use SHA1PRNG for key derivation, and use AES in ECB mode) I

.NET AES encryption and Android decryption

Daniel Warding I am using the following code to encrypt a GUID string using AES in .NET. // Decode the challenge bytes from base 64 byte[] challengeBytes = Base64.decode(challenge, Base64.NO_WRAP); ICryptoTransform encryptor = aes.Crea

Android encryption/decryption using AES

h4rd4r7c0r3: Is there a good example of how to encrypt and decrypt images and other files using AES on Android ? Nacho L.: Warning: this answer contains code that you shouldn't use because it's not secure (use SHA1PRNG for key derivation, and use AES in ECB mo

Improve the speed of encryption AES Android

Flo354 I have developed an android application for encrypting files on my phone. By searching, I found this thread: How to encrypt files from SD card using AES in Android? The method works fine, but encrypting the file is very slow... in this line: byte[] d =

Improve the speed of encryption AES Android

Flo354 I have developed an android application for encrypting files on my phone. By searching, I found this thread: How to encrypt files from SD card using AES in Android? The method works fine, but encrypting the file is very slow... in this line: byte[] d =

.NET AES encryption and Android decryption

Daniel Warding I am using the following code to encrypt a GUID string using AES in .NET. // Decode the challenge bytes from base 64 byte[] challengeBytes = Base64.decode(challenge, Base64.NO_WRAP); ICryptoTransform encryptor = aes.Crea

Android encryption/decryption using AES

h4rd4r7c0r3: Is there a good example of how to encrypt and decrypt images and other files using AES on Android ? Nacho L.: Warning: this answer contains code you shouldn't use because it's not secure (use SHA1PRNG for key derivation, and use AES in ECB mode) I

AES encryption and decryption algorithm in Android

username I am trying to encrypt and decrypt my data using AES algorithm in Android. this is my code package com.example.aesandroidsecurity; import java.security.NoSuchAlgorithmException; //import java.security.spec.AlgorithmParameterSpec; impor

Example of AES encryption with incorrect key size

confused person When encrypting with AES, you need a key size of 128, 192 or 256 bits. However, on various encryption sites, you can use any key that can even be 1 character long (8 bits). http://aesencryption.net/ For example, on that website I can use any ke

Example of AES encryption with incorrect key size

confused person When encrypting with AES, you need a key size of 128, 192 or 256 bits. However, on various encryption sites, you can use any key that can even be 1 character long (8 bits). http://aesencryption.net/ For example, on that website I can use any ke

Byte[] key encryption C# Aes

Limitless_ZA I am writing a program to save passwords and I am using Aes encryption method to encrypt and decrypt my files. Now here is my problem, I am doing it with this method. Every time I run the program it generates a new KEY and a new IV , but for the p

Android public key encryption

Rays: My Android app implements RSA encryption, but the backend cannot decrypt the token generated by the app. Below is the code, the start and end lines of the public key have been removed before making the call, what could be the problem? String encryptedTok

Android public key encryption

Rays: My Android app implements RSA encryption, but the backend cannot decrypt the token generated by the app. Below is the code, the start and end lines of the public key have been removed before making the call, what could be the problem? String encryptedTok

Store AES key in Android

Marius I want to store AES key in AndroidKeyStore on pre-M device I am trying to use the generated keyKeyGenerator KeyGenerator keyGen = KeyGenerator.getInstance(KeyProperties.KEY_ALGORITHM_AES); keyGen.init(256); SecretKey secretKey = keyGen.generateKey(); B

Store AES key in Android

Marius I want to store AES key in AndroidKeyStore on pre-M device I am trying to use the generated keyKeyGenerator KeyGenerator keyGen = KeyGenerator.getInstance(KeyProperties.KEY_ALGORITHM_AES); keyGen.init(256); SecretKey secretKey = keyGen.generateKey(); B

Where can I get the AES key plan encryption key?

Raptor I have implemented AES key scheduling in Java, but I am confused about it. In Wikipedia ( http://en.wikipedia.org/wiki/Rijndael_key_schedule#Key_schedule_description ) it says: The first n bytes of the extended key are just the encryption key. Where doe

Where can I get the AES key plan encryption key?

Raptor I have implemented AES key scheduling in Java, but I am confused about it. In Wikipedia ( http://en.wikipedia.org/wiki/Rijndael_key_schedule#Key_schedule_description ) it says: The first n bytes of the extended key are just the encryption key. Where doe

AES encryption for iOS and Android (UINT not in Java)

Eric: all, I'm new to crypto, so I don't know all the info I need to share to get help; but it's good that I know more about how to ask this question, and I'll revise the question :) I have AES encryption in both iOS and Android apps delivered to the device vi

AES encryption for iOS and Android (UINT not in Java)

Eric: all, I'm new to crypto so I don't know all the info I need to share to get help; but it's good that I know more about how to ask this question and I'll revise the question :) I have AES encryption in both iOS and Android apps delivered to the device via

AES encryption/decryption from Android to server

Berhag I have a server and two clients. The server runs Java and Jersey (Rest). One client is a Java client and the other is an Android client. I want to send a message encrypted with AES. So I have the following code (on server and client): cipher = Cipher.ge

AES encryption in android and decryption in php and vice versa

Pihu I am trying to learn AES by testing my code against https://aesencryption.net . I've had a bug before and also . So I somehow manipulated the Base64 to resolve the error. I think, now in my application the text is encrypted and decrypted correctly. Howeve

AES encryption in Android and decryption in Node.js

Nelson Joseph: I am trying to encrypt in android and decrypt in nodejs server. I generated an AES 128 bit key, encrypted it using the AES algorithm, then encrypted this generated key using the RSA algorithm. Then send both to the server. But when decrypting on

AES encryption in android and decryption in php and vice versa

Pihu I am trying to learn AES by testing my code against https://aesencryption.net . I've had a bug before and also . So I somehow manipulated the Base64 to resolve the error. I think, now in my application the text is encrypted and decrypted correctly. Howeve