且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

用于使用java加密和解密密码的API和算法

更新时间:2023-09-28 12:22:40

已更新 / p>

尝试JBCrypt:

  String password =MyPassword123; 
String hashed = BCrypt.hashpw(password,BCrypt.gensalt(12));
System.out.println(hash); // $ 2a $ 12 $ QBx3 / kI1SAfwBDFOJK1xNOXK8R2yC7vt2yeIYusaqOisYbxTNFiMy

下载jBCrypt-0.3 ,请查阅README文件了解更多详情。


I am currently creating application using Java, I googled password encryption with java but the results are so enormous I felt overwhelmed. How would I encrypt and decrypt a password using Java? And what is the best practice for encrypting and decrypting passwords? I am guessing MD5 is not a way to go since it is a one way hash. I am using struts2 as my framework, was wondering if they provide password encryption

Updated:

Try JBCrypt:

String password = "MyPassword123";
String hashed = BCrypt.hashpw(password, BCrypt.gensalt(12));
System.out.println(hashed);  // $2a$12$QBx3/kI1SAfwBDFOJK1xNOXK8R2yC7vt2yeIYusaqOisYbxTNFiMy

Download jBCrypt-0.3 from here, check README file for more details.