org.jasypt.exceptions.EncryptionOperationNotPossibleException

View: New views
8 Messages — Rating Filter:   Alert me  

org.jasypt.exceptions.EncryptionOperationNotPossibleException

by Srinivasa, Kadiyala :: Rate this Message:

| View Threaded | Show Only this Message

Dear All I am encrypting and decrypting a logging password. IF I am decrypting immediately after encrypting, the decryted value is fine and no exception is thrown. But if I am logging using the newly created username and password, I am getting the exception: org.jasypt.exceptions.EncryptionOperationNotPossibleException I have seen the notes in FAQ for this exception and did my best to fix the issue and could not. Appreciate help. My code: Encryption: StandardPBEStringEncryptor pwEncrypt = new StandardPBEStringEncryptor(); pwEncrypt.setPassword(mdhDashUser.getPassword()); pwEncrypt.setAlgorithm("PBEWithMD5AndDES"); RandomSaltGenerator salt = new RandomSaltGenerator(); salt.includePlainSaltInEncryptionResults(); // salt.setSalt("8"); pwEncrypt.setSaltGenerator(salt); pwEncrypt.setProvider(Security.getProvider("SunJCE")); pwEncrypt.setKeyObtentionIterations(2000); mdhDashUser.setPassword(pwEncrypt.encrypt(mdhDashUser .getPassword())); logger.debug("pw encrypted:" + mdhDashUser.getPassword() + ", pw decrypted: " + pwEncrypt.decrypt(mdhDashUser.getPassword())); Decryption: StandardPBEStringEncryptor pwDecrypt = new StandardPBEStringEncryptor(); if (userDetails != null && userDetails.getPassword() != null) pwDecrypt.setPassword(userDetails.getPassword()); pwDecrypt.setAlgorithm("PBEWithMD5AndDES"); RandomSaltGenerator salt = new RandomSaltGenerator(); pwDecrypt.setSaltGenerator(salt); pwDecrypt.setProvider(Security.getProvider("SunJCE")); pwDecrypt.setKeyObtentionIterations(2000); pwDecrypt.initialize(); if (pwDecrypt.isInitialized()) { logger.debug("decrypting password...." + userDetails.getPassword()); decryptedPw = pwDecrypt.decrypt(userDetails.getPassword()); } if (decryptedPw != null) { logger.debug("Decrypted Password from DB: " + decryptedPw); userDetails.setPassword(decryptedPw); } else { logger.debug("password not decrypted....."); }
Srinivasa, Kadiyala

Re: org.jasypt.exceptions.EncryptionOperationNotPossibleException

by dfernandez :: Rate this Message:

| View Threaded | Show Only this Message

+------------------------+
  Jasypt Users List      
  http://www.jasypt.org 
+------------------------+


Hello,

Are you storing the encrypted data into a database? a typical scenario for this error is encrypted data being corrupted during storage or transport (for example, because of a too short database column, or because of bad character encoding when transmitting via HTTP.

Regards,
Daniel.


skadiy000 wrote:
+------------------------+
  Jasypt Users List      
  http://www.jasypt.org  
+------------------------+
  



Dear All I am encrypting and decrypting a logging password. IF I am decrypting immediately after encrypting, the decryted value is fine and no exception is thrown. But if I am logging using the newly created username and password, I am getting the exception: org.jasypt.exceptions.EncryptionOperationNotPossibleException I have seen the notes in FAQ for this exception and did my best to fix the issue and could not. Appreciate help. My code: Encryption: StandardPBEStringEncryptor pwEncrypt = new StandardPBEStringEncryptor(); pwEncrypt.setPassword(mdhDashUser.getPassword()); pwEncrypt.setAlgorithm("PBEWithMD5AndDES"); RandomSaltGenerator salt = new RandomSaltGenerator(); salt.includePlainSaltInEncryptionResults(); // salt.setSalt("8"); pwEncrypt.setSaltGenerator(salt); pwEncrypt.setProvider(Security.getProvider("SunJCE")); pwEncrypt.setKeyObtentionIterations(2000); mdhDashUser.setPassword(pwEncrypt.encrypt(mdhDashUser .getPassword())); logger.debug("pw encrypted:" + mdhDashUser.getPassword() + ", pw decrypted: " + pwEncrypt.decrypt(mdhDashUser.getPassword())); Decryption: StandardPBEStringEncryptor pwDecrypt = new StandardPBEStringEncryptor(); if (userDetails != null && userDetails.getPassword() != null) pwDecrypt.setPassword(userDetails.getPassword()); pwDecrypt.setAlgorithm("PBEWithMD5AndDES"); RandomSaltGenerator salt = new RandomSaltGenerator(); pwDecrypt.setSaltGenerator(salt); pwDecrypt.setProvider(Security.getProvider("SunJCE")); pwDecrypt.setKeyObtentionIterations(2000); pwDecrypt.initialize(); if (pwDecrypt.isInitialized()) { logger.debug("decrypting password...." + userDetails.getPassword()); decryptedPw = pwDecrypt.decrypt(userDetails.getPassword()); } if (decryptedPw != null) { logger.debug("Decrypted Password from DB: " + decryptedPw); userDetails.setPassword(decryptedPw); } else { logger.debug("password not decrypted....."); }

View this message in context: org.jasypt.exceptions.EncryptionOperationNotPossibleException
Sent from the Jasypt - Users mailing list archive at Nabble.com.

------------------------------------------------------------------------------ This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword

_______________________________________________ jasypt-users mailing list jasypt-users@... https://lists.sourceforge.net/lists/listinfo/jasypt-users


------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
jasypt-users mailing list
jasypt-users@...
https://lists.sourceforge.net/lists/listinfo/jasypt-users

Re: org.jasypt.exceptions.EncryptionOperationNotPossibleException

by Srinivasa, Kadiyala :: Rate this Message:

| View Threaded | Show Only this Message

Hi Daniel

Thanks for the review & reply.

I am storing the password in Oracle 10g table. Data type is Varchar2(256byte).

1) Is the size sufficient?
2) How can I fix bad character encoding issue via HTTP?

Appreciate your review and inputs.

Thanks
Srinivasa N Kadiyala
dfernandez wrote:
+------------------------+
  Jasypt Users List      
  http://www.jasypt.org 
+------------------------+


Hello,

Are you storing the encrypted data into a database? a typical scenario
for this error is encrypted data being corrupted during storage or
transport (for example, because of a too short database column, or
because of bad character encoding when transmitting via HTTP.

Regards,
Daniel.


skadiy000 wrote:
> +------------------------+
>   Jasypt Users List      
>   http://www.jasypt.org 
> +------------------------+
>  
>
> ------------------------------------------------------------------------
>
> Dear All I am encrypting and decrypting a logging password. IF I am
> decrypting immediately after encrypting, the decryted value is fine
> and no exception is thrown. But if I am logging using the newly
> created username and password, I am getting the exception:
> org.jasypt.exceptions.EncryptionOperationNotPossibleException I have
> seen the notes in FAQ for this exception and did my best to fix the
> issue and could not. Appreciate help. My code: Encryption:
> StandardPBEStringEncryptor pwEncrypt = new
> StandardPBEStringEncryptor();
> pwEncrypt.setPassword(mdhDashUser.getPassword());
> pwEncrypt.setAlgorithm("PBEWithMD5AndDES"); RandomSaltGenerator salt =
> new RandomSaltGenerator(); salt.includePlainSaltInEncryptionResults();
> // salt.setSalt("8"); pwEncrypt.setSaltGenerator(salt);
> pwEncrypt.setProvider(Security.getProvider("SunJCE"));
> pwEncrypt.setKeyObtentionIterations(2000);
> mdhDashUser.setPassword(pwEncrypt.encrypt(mdhDashUser
> .getPassword())); logger.debug("pw encrypted:" +
> mdhDashUser.getPassword() + ", pw decrypted: " +
> pwEncrypt.decrypt(mdhDashUser.getPassword())); Decryption:
> StandardPBEStringEncryptor pwDecrypt = new
> StandardPBEStringEncryptor(); if (userDetails != null &&
> userDetails.getPassword() != null)
> pwDecrypt.setPassword(userDetails.getPassword());
> pwDecrypt.setAlgorithm("PBEWithMD5AndDES"); RandomSaltGenerator salt =
> new RandomSaltGenerator(); pwDecrypt.setSaltGenerator(salt);
> pwDecrypt.setProvider(Security.getProvider("SunJCE"));
> pwDecrypt.setKeyObtentionIterations(2000); pwDecrypt.initialize(); if
> (pwDecrypt.isInitialized()) { logger.debug("decrypting password...." +
> userDetails.getPassword()); decryptedPw =
> pwDecrypt.decrypt(userDetails.getPassword()); } if (decryptedPw !=
> null) { logger.debug("Decrypted Password from DB: " + decryptedPw);
> userDetails.setPassword(decryptedPw); } else { logger.debug("password
> not decrypted....."); }
> ------------------------------------------------------------------------
> View this message in context:
> org.jasypt.exceptions.EncryptionOperationNotPossibleException
> <http://www.nabble.com/org.jasypt.exceptions.EncryptionOperationNotPossibleException-tp21593682s21332p21593682.html>
> Sent from the Jasypt - Users mailing list archive
> <http://www.nabble.com/Jasypt---Users-f21330.html> at Nabble.com.
> ------------------------------------------------------------------------
>
> ------------------------------------------------------------------------------
> This SF.net email is sponsored by:
> SourcForge Community
> SourceForge wants to tell your story.
> http://p.sf.net/sfu/sf-spreadtheword
> ------------------------------------------------------------------------
>
> _______________________________________________
> jasypt-users mailing list
> jasypt-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jasypt-users
>  


------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
jasypt-users mailing list
jasypt-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jasypt-users
Srinivasa, Kadiyala

Re: org.jasypt.exceptions.EncryptionOperationNotPossibleException

by bornleo :: Rate this Message:

| View Threaded | Show Only this Message

Hello,

Just a thought.

Make sure all the encryption and decryption is being done with same algorithm and one more thing this was an issue in my case.Few passwords weren't encrypted.Which gave me the same error?

Hope this helps,
leo.

Re: org.jasypt.exceptions.EncryptionOperationNotPossibleException

by bornleo :: Rate this Message:

| View Threaded | Show Only this Message

One more thing

It seems you are using a randomsaltgenerator().

I am not an expert on this but may be this causes difefrent encryptions for randomly selected salts.

Well just a thought.

Leo.

Re: org.jasypt.exceptions.EncryptionOperationNotPossibleException

by Srinivasa, Kadiyala :: Rate this Message:

| View Threaded | Show Only this Message

Hi Leo

Thanks for the reply. I am using the same encryption methodology for decryption also.
I f I am decrypting immediately, it is decrypting.

After saving to Oracle 11g DB, when I tried to logon with the new username and password, I am getting this exception.

There was a reply by Daniel suspecting that the encoded string is getting corrupted in either Db or HTTP transmission.

I need some help how can I fix that?

Appreciate inputs.

Thanks
bornleo wrote:
Hello,

Just a thought.

Make sure all the encryption and decryption is being done with same algorithm and one more thing this was an issue in my case.Few passwords weren't encrypted.Which gave me the same error?

Hope this helps,
leo.
Srinivasa, Kadiyala

Re: org.jasypt.exceptions.EncryptionOperationNotPossibleException

by dfernandez :: Rate this Message:

| View Threaded | Show Only this Message

+------------------------+
  Jasypt Users List      
  http://www.jasypt.org 
+------------------------+


Hello,

As you are able to decrypt right afger encrypting, it doesn't seem to be a jasypt-related problem, but something related with the rest of your code.

I would suggest a "bracketing" approach to finding the bug:

  - First, check (log, for example), the encrypted text just after being encrypted, and then just before being decrypted (after retrieving it from DB). Check that they are not equal (they shouldn't, as for your description)
  - Then, check the differences between the encrypted text just after being encrypted and as stored in the database (using a tool like DBVisualizer).
  - Then, the differences between the data as stored in the database and as retrieved by your code
  - etc...

The goal is to corner your problem until you have it focused on a small part of your code.

Regards,
Daniel.


skadiy000 wrote:
+------------------------+
  Jasypt Users List      
  http://www.jasypt.org  
+------------------------+

Hi Leo

Thanks for the reply. I am using the same encryption methodology for
decryption also.
I f I am decrypting immediately, it is decrypting. 

After saving to Oracle 11g DB, when I tried to logon with the new username
and password, I am getting this exception.

There was a reply by Daniel suspecting that the encoded string is getting
corrupted in either Db or HTTP transmission. 

I need some help how can I fix that?

Appreciate inputs.

Thanks

bornleo wrote:
  
Hello,

Just a thought.

Make sure all the encryption and decryption is being done with same
algorithm and one more thing this was an issue in my case.Few passwords
weren't encrypted.Which gave me the same error?

Hope this helps,
leo.


    

  


------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
jasypt-users mailing list
jasypt-users@...
https://lists.sourceforge.net/lists/listinfo/jasypt-users

Re: org.jasypt.exceptions.EncryptionOperationNotPossibleException

by Srinivasa, Kadiyala :: Rate this Message:

| View Threaded | Show Only this Message

Hi Daniel & Leo

Good morning!

Thanks for replying to me.

I have done the exercise what you mentioned and would like to update you with the following information:

1) The password encrypted in logs and the password encrypted in DB are matching.
2) When I read the password again that is coming from DB and log it, that is also matching to the one I logged before storing to DB as well as in DB.
3) If I copy and paste the pw from DB for logging(of course it should not work) it is not working.

Daniel: As mentioned by Leo, i have commented the random salt generator and it did not help me.

Appreciate your valuable time and thanks again for the support.


dfernandez wrote:
+------------------------+
  Jasypt Users List      
  http://www.jasypt.org 
+------------------------+


Hello,

As you are able to decrypt right afger encrypting, it doesn't seem to be
a jasypt-related problem, but something related with the rest of your code.

I would suggest a "bracketing" approach to finding the bug:

  - First, check (log, for example), the encrypted text just after being
encrypted, and then just before being decrypted (after retrieving it
from DB). Check that they are not equal (they shouldn't, as for your
description)
  - Then, check the differences between the encrypted text just after
being encrypted and as stored in the database (using a tool like
DBVisualizer).
  - Then, the differences between the data as stored in the database and
as retrieved by your code
  - etc...

The goal is to corner your problem until you have it focused on a small
part of your code.

Regards,
Daniel.


skadiy000 wrote:
> +------------------------+
>   Jasypt Users List      
>   http://www.jasypt.org 
> +------------------------+
>
> Hi Leo
>
> Thanks for the reply. I am using the same encryption methodology for
> decryption also.
> I f I am decrypting immediately, it is decrypting.
>
> After saving to Oracle 11g DB, when I tried to logon with the new username
> and password, I am getting this exception.
>
> There was a reply by Daniel suspecting that the encoded string is getting
> corrupted in either Db or HTTP transmission.
>
> I need some help how can I fix that?
>
> Appreciate inputs.
>
> Thanks
>
> bornleo wrote:
>  
>> Hello,
>>
>> Just a thought.
>>
>> Make sure all the encryption and decryption is being done with same
>> algorithm and one more thing this was an issue in my case.Few passwords
>> weren't encrypted.Which gave me the same error?
>>
>> Hope this helps,
>> leo.
>>
>>
>>    
>
>  


------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
jasypt-users mailing list
jasypt-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jasypt-users
Srinivasa, Kadiyala