aspose file tools*
The moose likes Security and the fly likes Problem with encrypt and decrypt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Engineering » Security
Bookmark "Problem with encrypt and decrypt" Watch "Problem with encrypt and decrypt" New topic
Author

Problem with encrypt and decrypt

Charles Diskin
Greenhorn

Joined: Mar 03, 2006
Posts: 19
Hello, I am having a problem getting my servlet to decrypt a password. here is what I have so far...



The problem appears to be SecretKey,
it will run but it throws an exception in decrypt saying:

java.security.spec.InvalidKeySpecException: Password is not ASCII

Any help would be great, thanks in advance!

[ March 03, 2006: Message edited by: Charles Diskin ]
[Edit by Dave, code tags added]
[ March 03, 2006: Message edited by: David O'Meara ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60071
    
  65

Welcome to the Ranch.

A tip: few people are going to bother to read a large block of unformatted code. I'd suggest editing your post to restore the formatting by using the UBB code tags. The little CODE button under the entry area can help you out.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

I'm guessing that you'll have better luck with this one in the Security forum.
This one really isn't a servlet issue.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Charles Diskin
Greenhorn

Joined: Mar 03, 2006
Posts: 19
Thanks to the guys who moved my post to the right area and fixed up the code nice. I figured out this problem and now I'm having somet similar happen. the encrypted code is saved inside a microsoft access database column, when I try to pull it back out of the column and decrypt, it comes back as null, when there should be a value.

It works fine while just encrypting and decrypting but either something is going wrong while it's stored in the DB or it maybe it's a problem with the decryption function. If anyone has any ideas please post. PS: I can repost my decryption function code, I just wanted to know if anyone has had a similar problem before. This is the exception it throws:

javax.crypto.IllegalBlockSizeException: Input length must be multiple of 8 when decrypting with padded cipher

Any help, advice, etc; Thanks in advance!
Charles Diskin
Greenhorn

Joined: Mar 03, 2006
Posts: 19


Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39571
    
  27
Is the data you get out of the DB the same data you stuffed into it? If it's not, then this is really a DB issue, not a security issue.


Ping & DNS - updated with new look and Ping home screen widget
Charles Diskin
Greenhorn

Joined: Mar 03, 2006
Posts: 19
Thanks for the reply, we narrowed it down to a DB problem, encrypted number going into the database, and on return it is decrypted to a null. We were using an Access database and now we are going to create a whole new system in MySQL. Maybe I can try a Database board and see if they have a solution for the MS Access decrypt problem. Once again thanks for the feedback!
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39571
    
  27
"a database board" ??? What are you talking about? We have a JDBC forum right here! Don't you dare go someplace else
Charles Diskin
Greenhorn

Joined: Mar 03, 2006
Posts: 19
Sorry didn't mean offense, that is in fact where I went. Don't know what I was thinking it was getting late at work yesterday when I posted that Thanks for the help
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem with encrypt and decrypt
 
Similar Threads
URGENT...HELP IN JCE
Trouble decrypting from an Access DB w/ weird exception
Urgent Help In Cryptogarphy.....JCE EXPERTS PLZ HELP
Encryption/Decryption using java or oracle
PBEWithMD5AndDES Algorithm Exception