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 producing different values on different platforms

ak47Dec 13 2018 — edited Dec 13 2018

Hi,

I am using AES encryption algorithm to encrypt the string on android device and then decrypting it on the server in order to fetch the data.

The problem I am facing is that the encrypted string that I am getting is giving "badPaddingException" while decrypting.

Below is the code for encryption and decryption.

For decryption(On server) ->

public static String decrypt(String message, String encryptionKey) throws Exception {

try {

setIvPair(encryptionKey.getBytes("UTF-8"), ivString.getBytes("UTF-8"));

Cipher cipher = getCipher(Cipher.DECRYPT_MODE);

byte[] encryptedTextBytes = BaseEncoding.base64().decode(message);

byte[] decryptedTextBytes = cipher.doFinal(encryptedTextBytes);

return new String(decryptedTextBytes);

} catch (IllegalBlockSizeException | BadPaddingException | InvalidKeyException

| InvalidAlgorithmParameterException | UnsupportedEncodingException e) {

log.debug("Unable to decrypt message :: " + e.getMessage());

throw new Exception(e);

}

For encryption(On MobileApp) ->

public static String encrypt(String message, String encryptionKey) throws Exception {

try {

setIvPair(encryptionKey.getBytes("UTF-8"), ivString.getBytes("UTF-8"));

Cipher cipher = getCipher(Cipher.ENCRYPT_MODE);

byte[] encryptedTextBytes = cipher.doFinal(message.getBytes("UTF-8"));

return BaseEncoding.base64().encode(encryptedTextBytes);

} catch (IllegalBlockSizeException | BadPaddingException | UnsupportedEncodingException | InvalidKeyException

| InvalidAlgorithmParameterException e) {

log.info("Unable to encrypt message :: ", e);

//e.printStackTrace();

throw new Exception("Unable to encrypt message");

}

}

The string being encrypted is of length 10, and the token used to encrypt it is "f15c3316a539466c924f35215b806989".

The encrypted value which I am getting from the app is "t3XMYQ2NZ62Yg7KO1/smrQ==", however, the value which I should get is "Vjs6tvfz+JqNalf3s9mWaA==".

I have debugged the code and checked the values of the parameters and matched the same with the one in the app, everything seems to be in sync.

Can somebody help me out here, any help is appreciated.

Thanks in advance.

Comments

Srini Chavali-Oracle

Win Home versions are not certified for Oracle database installs - Oracle Database Preinstallation Tasks

so expect such issues. Is there a reason you cannot use a supported OS version ?

After powering up the laptop, is the database up and running ? You will have to start up the database and listener before you can access the EM Express page - Getting Started with Database Administration

HTH
Srini

user6880652

Hi Srini,

I have also installed Weblogic 12C, and the Weblogic em is working fine as expected. Not sure why the issue comes with Oracle EM only

Possibly because you are using an unsupported version of the OS

Srini

TSharma-0racle

user6880652 wrote:

I installed 12C Enterprise on my laptop that has Windows 7 Home .The installation process went fine and I was able to connect to http://localhost:5500/em (even used). But, once I powered down my laptop and brought it back up the next day, I couldn't connect ('the page cannot be displayed'). So, I uninstalled oracle and then tried the process again. I could initially connect to 5500/em but after rebooting or powering down the machine, I could not find http://localhost:5500/em.

Can anyone direct me to some specific documentation with this or has anyone conclusively solved this problem to the end????? Thanks for any help.

Shouldn't you be in connecting to HTTPS instead of HTTP(http://localhost:5500/em) OR it is just a typo?

What if you try

https://localhost:5500/em

1 - 4

Post Details

Added on Dec 13 2018
0 comments
393 views