how to decrypt hashcode? ist the same with decode?? how can i decrypt/decode this code? could someone help me.
enter.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
// TODO Auto-generated method stub
String a = txtID.getText().toString();
int b = a.hashCode();
txtCode.setText(b);
}
}
like, it will read the codes backward and display the original data that has been hashed and trimmed.
how to decrypt hashcode? ist the same with decode?? how can i decrypt/decode this code? could someone help me.
enter.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
// TODO Auto-generated method stub
String a = txtID.getText().toString();
int b = a.hashCode();
txtCode.setText(b);
}
}
like, it will read the codes backward and display the original data that has been hashed and trimmed.
Share Improve this question edited Dec 14, 2015 at 19:30 ehehhh 1,0743 gold badges16 silver badges27 bronze badges asked May 30, 2013 at 0:04 DrxDrx 1671 gold badge2 silver badges12 bronze badges 4-
6
The
hashCode
function generally uses a lossy algorithm, so this usually cannot be done. – Shadow Man Commented May 30, 2013 at 0:07 - Indeed, a hash should not be reversed. You need to use crypt function instead, not hash functions. – MatRt Commented May 30, 2013 at 0:09
- Hashes are one-way functions. By design, they cannot be reversed. – hellerve Commented May 30, 2013 at 0:09
- 1 To put it in context, a hashcode is an int or 32 bits. So, even if it could be reversed, the original value could not contain more than 32 bits of information... – SJuan76 Commented May 30, 2013 at 0:11
2 Answers
Reset to default 2The hashCode method es from java.lang.Object and should (must?) follow the contract below:
- Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals parisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
- If two objects are equal according to the equals(Object) method, then calling the hashCode method on each of the two objects must produce the same integer result.
- It is not required that if two objects are unequal according to the equals(java.lang.Object) method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hashtables.
I am not sure what you mean by "decrypt hashCode" in that context and it may not be the feature/behavior your are looking for here.
For further information: http://docs.oracle./javase/7/docs/api/java/lang/Object.html#hashCode()
You seem to be misunderstanding what Object's .hashCode()
is about. It is by no means a "cryptographically secure" hash of a given object.
Its only role is to obey the .equals()/.hashCode() contract. And the contract basically has one rule: if two object instances are considered equal, their hash code should be equal. And that's about it.
This is a perfectly legal hashCode() implementation:
@Override
public int hashCode() {
return 42; //legal but useless
}
The most prominent use of this function is when used in Set
s. This therefore include the use as keys in Map
s. In both cases, the underlying use is hash tables. Which is why the hash algorithm used should have a decent distribution.