Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java two way encryption library [duplicate]

I need to save a db password as an encrypted string and then decrypt before connecting.

Can anyone refer me a good two-way encryption library in Java?

like image 740
Dan Avatar asked Nov 02 '11 11:11

Dan


3 Answers

Dan, take a look at this thread as there is some useful info on how to do that in a property file just via Java's APIs.

Encrypt Password in Configuration Files?

like image 90
Mechkov Avatar answered Oct 17 '22 20:10

Mechkov


In real terms of security Base64 encoding will be almost as good as any "hard" encryption.

(Dispute in comments. :) )

Edit: OK, the recent downvote brought me back here to add some words.

The above statement is meant to remind people that it is impossible to have any automated activity authenticate in a secure way to some other party. If you'd use a password to encrypt and decrypt a stored password, where would you store this new password? Easy! Just make a third password to securely store the second password and so on.

Point is: Any password which is decryptable by some automatic procedure is in fact not encrypted but merely obfuscated. Thus, the encryption is futile in the first place.

like image 35
JimmyB Avatar answered Oct 17 '22 21:10

JimmyB


Usually passwords are kept as hash, so the process of getting the real password is not possible, other than converting it back what we do is we convert the password user entered to a hash and then match them. If you can explain more about your usecase it'll be clear

like image 36
imal hasaranga perera Avatar answered Oct 17 '22 21:10

imal hasaranga perera