This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Security and the fly likes Decryption fails on Mac Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » Security
Bookmark "Decryption fails on Mac" Watch "Decryption fails on Mac" New topic

Decryption fails on Mac

Sudhanshu Umalkar

Joined: Nov 19, 2002
Posts: 12
If I encrypt a string using some algorithm and javax.crypto API, I cannot decrypt it on Mac. I guess it has something to do with the encoding.
Any solution for this?


Sudhanshu Umalkar

Joined: Nov 19, 2002
Posts: 12
It works fine only on Windows platform, but not on others.
greg stark
Ranch Hand

Joined: Aug 10, 2006
Posts: 220
Sud Umm wrote:It works fine only on Windows platform, but not on others.

You can't use SecureRandom in the way you are doing it. SecureRandom does NOT only use your seed to initialize itself, it also may seek to use other sources of entropy. This should be made clear in the Javadocs for SecureRandom; unfortunately it is not.

You should use a proper Password-based encryption (PBE) scheme.

Nice to meet you.
Maarten Bodewes

Joined: Aug 04, 2011
Posts: 14
About the exception handling: use BadPaddingException and then GeneralSecurityException - and convert at least the last one into a InvalidStateException. You can avoid the encoding exceptions by using Charset.forName() in later VM's. Note that any encoding is accepted by default, the exception normally only gets thrown if the encoding is not available; but Java specifies that "UTF-8" is ALWAYS available, so that's a bit of a moot point.
I agree. Here's the link:
subject: Decryption fails on Mac
Similar Threads
ORA-29532: Java call terminated by uncaught Java exception: java.lang.NullPointerExce
error coming while decrypting...
BadPaddingException using DES
Encryption/Decryption using Blowfish algorithm
What broke between 1.4 and 1.6 for decryption?