是否有可能从MD5和Java恢复消息? [英] Is it possible to recover message from MD5 and Java?

查看:90
本文介绍了是否有可能从MD5和Java恢复消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码。

  String plaintext =HelloWorld; 
MessageDigest m = MessageDigest.getInstance(MD5);
m.reset();
m.update(plaintext.getBytes());
byte [] digest = m.digest();
BigInteger bigInt = new BigInteger(1,digest);
String hashtext = bigInt.toString(16);

//现在,如果您真的想要完整的32个字符,我们需要将其填充。 $(b)b while(hashtext.length()<32){
hashtext =0+ hashtext;
}

现在我想将它转换回原始字符串。是否有可能?

解决方案


我已经试过了。现在我想将它转换回原始字符串。

这对于MD5是不可能的。这是一个单向散列函数



为了为了能够加密和解密,您需要使用像AES这样的加密/解密算法。

参见 Java™加密体系结构(JCA)参考指南获取更多信息。


I have the following code.

String plaintext = "HelloWorld";
MessageDigest m = MessageDigest.getInstance("MD5");
m.reset();
m.update(plaintext.getBytes());
byte[] digest = m.digest();
BigInteger bigInt = new BigInteger(1,digest);
String hashtext = bigInt.toString(16); 

// Now we need to zero pad it if you actually want the full 32 chars.
while(hashtext.length() < 32 ){
    hashtext = "0"+hashtext;            
}

Now I want to convert it back to the original string. Is it possible?

解决方案

I have tried this. Now I want to convert it back to Original string.

This is not possible with MD5. It is a one-way hash function.

In order to be able to encrypt and decrypt, you need to use an encryption/decryption algorithm like AES.

See Java™ Cryptography Architecture (JCA) Reference Guide for more information.

这篇关于是否有可能从MD5和Java恢复消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆