The following code i search some where from websites.
it generate hash value for a string.
but is that possible that convert it back to original string ?
like if the string is "this is string" and hash value is "dje3h344h3hk4w 9sjs" (just an example)...
so how i'm going to make the hash value back to original string ?
can anyone help ?
i am a noob on this situation.
it generate hash value for a string.
but is that possible that convert it back to original string ?
like if the string is "this is string" and hash value is "dje3h344h3hk4w 9sjs" (just an example)...
so how i'm going to make the hash value back to original string ?
can anyone help ?
i am a noob on this situation.
Code:
public class Encryptor {
public static String toHexString(byte [] ab) {
StringBuffer sb = new StringBuffer(ab.length * 2) ;
for(int i=0; i<ab.length; ++i) {
String sTemp = Integer.toHexString(0xFF & ab[i]) ;
if(1==sTemp.length()) {
sb.append("0") ;
}
sb.append(sTemp) ;
}
System.out.println(sb.toString());
return sb.toString() ;
}
public static String genHash(String s)
{
byte[] ab = new byte[25];
try {
com.sun.midp.ssl.MessageDigest md = com.sun.midp.ssl.MessageDigest.getInstance(com.sun.midp.ssl.MessageDigest.ALG_SHA, true);
md.update(s.getBytes(), 0, s.length()) ;
System.out.println("in genHash method");
System.out.println("\t" + s);
System.out.println("\t" +md);
short sh = md.doFinal(s.getBytes(), 0, s.length(), ab, 0 );
System.out.println("\tsh = "+ sh);
} catch (com.sun.midp.ssl.CryptoException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
return toHexString(ab) ;
}
}
Comment