如何从hashCode获取字符串 [英] how can I get the String from hashCode

查看:697
本文介绍了如何从hashCode获取字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在一个项目中,我获得了密码字段值的 hashCode 并将该hashCode出于安全目的存储在DB中.现在我想从hashCode中恢复密码.它? 是否可以从hashCode中获取String值?否则,是否有人可以建议,以更好的方式以其他格式存储密码?

I am working on a project where I had got my password field value's hashCode and stored that hashCode in DB for security purposes.Now I want to recover the password from the hashCode.How can I do it? Is it possible to get the String value back from the hashCode?If it is not, can anyone suggest me a better way to store my password in anyother format?

推荐答案

您知道几个对象可以具有相同的hash(),正如Java文档中针对Object.hashCode()

You know that several objects can have same hash(), as it mentioned in java doc for Object.hashCode()

要求两个对象不相等 *根据{@link java.lang.Object#equals(java.lang.Object)} *方法,然后在每个 *两个对象必须产生不同的整数结果.

It is not required that if two objects are unequal * according to the {@link java.lang.Object#equals(java.lang.Object)} * method, then calling the {@code hashCode} method on each of the * two objects must produce distinct integer results.

很明显,您无法从同一哈希码恢复不同的对象,因此,简单的逻辑根本不可能.

It's obvious you can't restore different objects from same hash code, so it's impossible at all, simple logic.

这篇关于如何从hashCode获取字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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