-1

I am creating a SHA384 hash. I want to decode that hash. Is there any possible way to do this? Please help

Following is the code to get hash

public String getHash(String message) {
    String algorithm = "SHA384";
    String hex = "";
    try {
        byte[] buffer = message.getBytes();
        MessageDigest md = MessageDigest.getInstance(algorithm);
        md.update(buffer);
        byte[] digest = md.digest();

        for(int i = 0 ; i < digest.length ; i++) {
            int b = digest[i] & 0xff;
            if (Integer.toHexString(b).length() == 1) hex = hex + "0";
            hex  = hex + Integer.toHexString(b);
        }
        return hex;
    } catch(NoSuchAlgorithmException e) {
        e.printStackTrace();
        return null;
    }

}
user3864752
  • 143
  • 3
  • 15

1 Answers1

4

A cryptographically secure hashing function is a function such that a given arbitrary length input is processed into a fixed length output in such a way that is not reversible (computationally infeasible). Such functions include MD5 and the SHA (Secure Hash Algorithm) family (1, 224, 256, 384, 512, etc).

Once you take the hash of the input there is no going back to the original input. This property can be used for verification of message integrity as hashing the identical message produces a identical hash.

The website you visited simply stores hashes and their inputs side by side and does a database lookup for your hash to attempt to find a possible input (if it was previously added to the database).

initramfs
  • 8,275
  • 2
  • 36
  • 58
  • can i do that way? like by creating my own database and storing hash in it and does a database lookup for decoding? – user3864752 Jul 23 '14 at 09:31
  • @user3864752 Yes you could, but you would need to build a infinitely large database to hold all possible input. I don't really understand what you are trying to do with that. And what you would be doing is not called `decoding` but rather a simple table lookup. – initramfs Jul 23 '14 at 09:37
  • yeah thats right. But there is one other problem. I am encrypting in C# and want to decrypt in Android/java – user3864752 Jul 23 '14 at 09:54
  • And what about this http://developer.android.com/reference/javax/crypto/Cipher.html class. Can we use it for decryption – user3864752 Jul 23 '14 at 10:01
  • @user3864752 If you are looking at data encryption, hashing algorithms are not the way to go. Consider ciphers like AES for symmetrical encryption. The Cipher class you suggested can be used for AES so you can read in on that. – initramfs Jul 23 '14 at 11:08
  • Please help me here http://stackoverflow.com/questions/24908826/encryption-and-decryption-using-aes-algorithms – user3864752 Jul 23 '14 at 11:10