• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Encryption in Java

 
Venkat Kommareddy
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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

--Venkat.
 
Paul Clapham
Sheriff
Posts: 20986
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
continue to my previous reply.

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

Thanks.

 
Devaka Cooray
ExamLab Creator
Marshal
Pie
Posts: 4328
238
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Venkat Kommareddy
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I dont want password back. I just need to check whether that string is encrypted or not. is there solution?

Thanks.
 
Paul Clapham
Sheriff
Posts: 20986
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 781
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic