java - 从 SHA 哈希到密码
问题描述
所以我已经编写了这段代码来转换为我的密码的哈希值,我现在想要获取哈希值并将其转换回字符串。怎么可能做到这一点?
package security;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class HashPassword {
public static String hashPassword(String password) throws NoSuchAlgorithmException
{
MessageDigest sha= MessageDigest.getInstance("SHA");
sha.update(password.getBytes());
byte [] b=sha.digest();
StringBuffer sb= new StringBuffer();
for(byte b1:b)
{
sb.append(Integer.toHexString(b1 & 0xff).toString());
}
return sb.toString();
}
public static void main(String[] args)
{
String password="1234";
System.out.println(password);
try
{
System.out.println(hashPassword(password));
}catch(NoSuchAlgorithmException e)
{}
}
}
解决方案
你可以尝试用Rainbow table破解它
推荐阅读
- ios - 出现错误:“找不到 -lDoubleConversion 的库”,使用 React 本机 0.61.4 和 xcode 12.1 尝试产品 -> 存档
- sql-server - 选择带有 if 表达式的列
- python - 仅当列存在时,带有列表达式的 pyspark
- azure-devops - 如何使用 rest api 在 Azure DevOps 中获取发布管道名称列表
- java - Spring JPA在不同的查询中返回空列表
- c# - 在 C# 中将公共证书与私有 RSA 密钥相结合
- c++ - 动态数组:尝试正确扩展动态数组并尝试从函数返回非 NULL 值
- python - PySpark:如何根据事件创建自上次事件计数器和唯一标识符以来的时间?
- c# - 模型项为空
- ruby-on-rails - 尝试访问受 Devise JWT 保护的 API 时出现“没有可用的验证密钥”