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

本文介绍了如何在Java中使用BCrypt库进行密码的加密和解密,以确保密码的安全性。BCrypt是一种强加密算法,适合用于存储密码。示例代码展示了如何使用BCrypt.hashpw()和BCrypt.checkpw()方法进行密码的加密和验证。更新内容推荐使用BCrypt-0.3版本,并提供了下载链接和README文件以获取更多信息。
摘要由CSDN通过智能技术生成

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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值