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


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » Security
Bookmark "Encryption in Java" Watch "Encryption in Java" New topic
Author

Encryption in Java

Venkat Kommareddy
Greenhorn

Joined: Apr 28, 2011
Posts: 8
Hi,

I have requirement to see given string is encrypted or not. Please help me on this.

--Venkat.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18657
    
    8

Can you be more precise? In general a string is just a sequence of characters. Encrypting that normally produces a sequence of bytes (because encryption works on bytes), but let's suppose you were thinking of some other kind of encryption which produces characters as its output.

Now, given no other requirements, there isn't any way to tell whether some arbitrary sequence of characters is the result of some unknown encryption algorithm given some other arbitrary sequence of characters as its input. So you need more requirements before you can answer that.
Venkat Kommareddy
Greenhorn

Joined: Apr 28, 2011
Posts: 8
Thanks for your reply. I understand your point.
I have encrypted password like "n/yBWibTa1Y=". how to I confirm whether it is encrtypted password or not.. is there way to find it using java?

Thanks.
Venkat Kommareddy
Greenhorn

Joined: Apr 28, 2011
Posts: 8
continue to my previous reply.

based on confirmation I have to do decrypt for that string in my code.

Thanks.

Devaka Cooray
ExamLab Creator
Saloon Keeper

Joined: Jul 29, 2008
Posts: 3166
    
  47

Venkat Kommareddy wrote:I have encrypted password.... I have to do decrypt for that string in my code

You can't. Passwords are generally encrypted with one-way hashing algorithms, and there isn't a way to get the original password back from the hashed value.


Author of ExamLab ExamLab - a free SCJP / OCPJP exam simulator
What would SCJP exam questions look like? -- Home -- Twitter -- How to Ask a Question
Venkat Kommareddy
Greenhorn

Joined: Apr 28, 2011
Posts: 8
I dont want password back. I just need to check whether that string is encrypted or not. is there solution?

Thanks.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18657
    
    8

So you're given a password in clear-text and you want to know whether a particular string is the encrypted version of that password? Then just encrypt the clear-text password and see if you get that particular string.
James Sabre
Ranch Hand

Joined: Sep 07, 2004
Posts: 781

Paul Clapham wrote:So you're given a password in clear-text and you want to know whether a particular string is the encrypted version of that password? Then just encrypt the clear-text password and see if you get that particular string.


This will only work if there is no random component in the encryption. Assuming that a randomly seeded hash has been used then it is normal to place the seed in the clear within the 'encrypted' result so one must extract it first and use it in exactly the same way as it was used in the original hash. But of course until the OK says exactly how the 'encrypted' value was generated one is only guessing.


Retired horse trader.
 Note: double-underline links may be advertisements automatically added by this site and are probably not endorsed by me.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Encryption in Java