Securely saving password locally java? [duplicate]
开发者_运维知识库Possible Duplicate:
What is the best practice for securely storing passwords in Java
I am working on a java application and would like to save password locally on a file. I am not sure how to achieve this, any help would be appreciated.
You don't provide much information for this.
My first advice would be not to save the password per se, but instead save its hash value.
When you need to verify that someone has provided the correct password just compare the hashes.
You could use for example MD5
for this Message Digest
If you need to be able to retrieve the password then you have to encrypt it.
For that you could use e.g. AES
AES in Java but for symmetric encryption you have a new problem now, where to store the decryption key.
It depends on what you want to do and requirement.
Your question does not say much
You can use AES / DES algorithm and write the encrypted password to disk.
I finaly figured it out. What I did was simply converte the charecters into ascii code and then add or subract depending on the the situation.
精彩评论