Java/Scala 双向 MD5
我试图找到一些如何获取字符串并使用 MD5 对其进行哈希处理的示例,然后能够将哈希值(正确的术语?)反转回原始字符串。
有谁知道任何文档可以显示如何做到这一点,或者最好有他们可以分享的任何示例代码?
我读过有关 java.security.MessageDisgest 类的内容,但这似乎只是单向的。我需要能够将哈希值转换回其原始数据。 MD5 是最好使用的算法,还是我应该完全考虑其他算法?
I am trying to find some samples of how to take a string and hash it using MD5, and then be able to reverse hash (correct term?) back to the original string.
Does anyone know of any documentation that shows how this can be done, or ideally has any sample code they could share?
I've read about the java.security.MessageDisgest class, but that appears to be only one-way. I need to be able to convert the hash back into its original data. Is MD5 the best algorithm to use, or should i be looking at something else entirely?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
MD5具有破坏性。散列时您会丢失数据。
也许您正在寻找像 DES 或(更好的)AES 这样的对称密码?
bouncycastle 安全提供程序在 http://www.bouncycastle.org/specifications.html< 处提供了 DES 实现示例/a>
编辑:抱歉,我操之过急。您的目标是什么:压缩、索引、校验和、加密还是其他?
MD5 is destructive. You lose data when you hash.
Perhaps you are looking for a symmetric cipher like DES or (better) AES?
The bouncycastle security provider has a DES implementation example at http://www.bouncycastle.org/specifications.html
EDIT: Sorry, I've jumped the gun. What is your objective: Compression, Indexing, Checksumming, Encryption, or something else?
哈希函数被设计为不可逆的。
您需要的是使用安全传输层,例如 SSL 或 TLS(例如:HTTPS 是带有 SSL 或 TLS 的 HTTP)。
请不要自行推出关于这一点。
请注意,在客户端上简单地使用像 AES 这样的对称密码(例如:Javascript)是没有用的,因为您需要向所述客户端提供密钥,这样攻击者就能够轻松解密任何截获的消息。
Hash functions are designed to be irreversible.
What you need is to use a secure transport layer, like SSL or TLS (eg: HTTPS is HTTP with SSL or TLS).
Please refrain from rolling your own on this one.
Note that simply using a symmetric cypher like AES on the client (eg: Javascript) is useless, because you'd need to supply the key to said client and thus an attacker would be able to trivially decrypt any intercepted messages.