-
January 28th, 2010, 03:36 PM
#1
MD5 Decryption in Java
Hello everyone ,
First of all I would like to compliment everyone because this forum is really nice and it does provide so many information.
I have a task to perform and I would like to know if is possible to decrypt a hash key to know the original string value.
As far as I can see by browsin is that this is not possible and the only way to this is to encrypt and compare hashes.
Can someone tell if there is a way to decrypt MD5 hash keys or in a way or other find out whats the hash key is using java ?
thank you in advance
-
January 28th, 2010, 05:32 PM
#2
Re: MD5 Decryption in Java
You can't decrypt the MD5 hash value as its a one way process. However, if the MD5 algorithm produced a different hash value for every possible input (which it doesn't), it would be possible to discover the original string. The simplest approach would be to try every possible input until you found the one that produced the same hash value - this might take some time though!! Of course even after many hours of computing you may just find an MD5 collision rather than the original message.
There may be a better approach to discovering the original message but I'm no expert on cryptography. Maybe someone else can provide a more detailed response.
-
January 28th, 2010, 07:15 PM
#3
Re: MD5 Decryption in Java
yeah thanks for you answers, as i was expecting md5 cannot be decrypt.
Therefore I would like to ask if there is a java classs and some tutorial that explain how to make md5 hashes and then compare them to the one which needs to be decrypt
I already know which is going to be answer
like some questions give me the md5 hash and ask me to find the original value by statin that is a 3 digit integer number between 100-999
other ask me to find an equation ....
so is it there any class that makes md5 hashes for strings we are looking for?
-
January 29th, 2010, 07:27 AM
#4
Re: MD5 Decryption in Java
It's time to use that wonderful tool called google.
Just search for something like "Java MD5" and read some of the hits.
-
January 29th, 2010, 12:36 PM
#5
Re: MD5 Decryption in Java
thank you guys
I have tried to load an MD5 ENCRYPTER and then use it to make comparisons so whenever it finds the to equal strings it will give me an output, however it does not give me the right MD5 output
this is the code
import java.security.*;
public class MD5Encrypt {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
boolean chk=false;
String hash,id;
hash="F61D6947467CCD3AA5AF24DB320235DD"; //this is the hash key that I want to decrypt and the original value of this is 375
hash=hash.toLowerCase();
for (int i=100; i<=999;i++) /* over here i do a loop that start from 100 to 999 so it will generat hash keys for all the numbers and while it generates them it will also compare them in a method */
{
id=Integer.toString(i);
md5Enc(id,hash, chk);
if (chk==true)
{
break;
}
}
}
static void md5Enc (String sessionid, String hashKey,boolean found)
{
//sessionid="12345";
byte[] defaultBytes = sessionid.getBytes();
try{
MessageDigest algorithm = MessageDigest.getInstance("MD5");
algorithm.reset();
algorithm.update(defaultBytes);
byte messageDigest[] = algorithm.digest();
StringBuffer hexString = new StringBuffer();
for (int i=0;i<messageDigest.length;i++) {
hexString.append(Integer.toHexString(0xFF & messageDigest[i]));
}
String foo = messageDigest.toString();
String generatedKey=hexString.toString();
if (generatedKey.equals(hashKey)) /this is the comparison
/but when it generates the hash key for
{ /375 it does generate a different hash
System.out.println("The original value of the MD5 Hash "+ hashKey +" is : " + sessionid);
found=true;
}
//String key1,key2;
//key1=hashKey;
//key2=hexString.toString();
//
//System.out.println("sessionid "+sessionid+" md5 version is "+hexString.toString());
//sessionid=hexString+"";
}catch(NoSuchAlgorithmException nsae){
}
}
}
-------------------------------------------------
please help me with this/
-
January 29th, 2010, 01:38 PM
#6
Re: MD5 Decryption in Java
People don't generally want to take wild guesses at what is wrong. What is the output it is generating? What is the output that you are expecting? What do YOU think is happening? Have you tried to narrow it down at all?
-
January 29th, 2010, 02:15 PM
#7
Re: MD5 Decryption in Java
There is something wrong with the generation of the mD5 HASHES,and this is the reason why I cannot figured it out as it is a class that I am loading and found out from the enternet as someone suggested it in this forum.
The value is 375 and the hash is :f61d6947467ccd3aa5af24db32235dd
I know this because I checked it on internet.
I want to decrypt the hash f61d6947467ccd3aa5af24db32235dd so I know the originale value(375)
as is not possible to decrypt it ,the only way is to generate hashes for every single number and then compare them which is what i have done but when it generates the value for 375 it does give me this value instead :>>>> f61d6947467ccd3aa5af24db320235dd
-
January 29th, 2010, 02:54 PM
#8
Re: MD5 Decryption in Java
The result you get (f61d6947467ccd3aa5af24db320235dd) has 32 hex digits and the hash you claim corresponds to 375 (f61d6947467ccd3aa5af24db32235dd) has 31. Are you sure the latter is a valid hash? MD5 produces 128-bit=16-byte=32-hex digits hashes.
-
January 29th, 2010, 03:02 PM
#9
Re: MD5 Decryption in Java
so what are you saying that this hash is wrong > F61D6947467CCD3AA5AF24DB320235DD
because this is the hash that it has been told me to decrypt and I am not gettin that value when I run the program to encrypt integer numbers
What do you think is wrong in this case?
-
January 29th, 2010, 03:27 PM
#10
Re: MD5 Decryption in Java
Originally Posted by cpu2007
There is something wrong with the generation of the mD5 HASHES,and this is the reason why I cannot figured it out as it is a class that I am loading and found out from the enternet as someone suggested it in this forum.
The value is 375 and the hash is :f61d6947467ccd3aa5af24db32235dd
I know this because I checked it on internet.
I want to decrypt the hash f61d6947467ccd3aa5af24db32235dd so I know the originale value(375)
as is not possible to decrypt it ,the only way is to generate hashes for every single number and then compare them which is what i have done but when it generates the value for 375 it does give me this value instead :>>>> f61d6947467ccd3aa5af24db320235dd
You said that this hash is wrong. You posted two hashes saying the first one is the one you want to decrypt and the other one is the result you get with your method, implying it is wrong.
-
January 29th, 2010, 03:30 PM
#11
Re: MD5 Decryption in Java
exactly thats right ...so what is the problem here...how can i make it work right?
-
January 29th, 2010, 07:16 PM
#12
Re: MD5 Decryption in Java
The hash you 'checked on the internet' is exactly the same except for a single digit (0), and, coincidentally, is short by that same digit. So what does common sense tell you about the internet hash value?
Good teaching is more a giving of the right questions than a giving of the right answers...
J. Albers
Please use [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.
-
January 30th, 2010, 06:11 AM
#13
Re: MD5 Decryption in Java
I dont understand much of this
The hash that has been given to me to be decrypted is 32 bytes and the one that has been generated through the MD5 java class is 21 bytes right?
I do understand that at the end of the day they are similar,but how do I make them generate the same value as the question one.
This time i knew that the hash original value was 375 but in the next questions I will not know the original values so I will need to compare the the hash that will be asked me to compare plus the generated hash and when they will be equal I will be able to know the original value.
-
January 30th, 2010, 06:47 AM
#14
Re: MD5 Decryption in Java
Originally Posted by cpu2007
The hash that has been given to me to be decrypted is 32 bytes and the one that has been generated through the MD5 java class is 21 bytes right?
No - unless you're talking about some other hash value. You've posted two hashes, one of 32 bytes and one of 31 bytes. From your previous posts, the 32 byte one is the one you generated and the 31 byte one is the hash you 'checked on the internet'. Maybe the internet one is missing a byte - just a thought...
Computers are like bikinis. They save people a lot of guesswork...
Sam Ewing
Please use [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.
-
January 30th, 2010, 10:16 AM
#15
Re: MD5 Decryption in Java
This is one is one that has been given me by my tutor and he asked me to decrypt it withouth using internet.
F61D6947467CCD3AA5AF24DB320235DD
This is the one generated by using the code that I have posted in the previous thread
f61d6947467ccd3aa5af24db32235dd
--------------------------------------------------------------------------
Now why are they different, i mean has my tutor given me a wrong hash? I don't think so as I put that hash on google it comes up with the value 375
and furthermore when I use the code to generate the hashes it comes up with a different hash for 375.
So I really want to know if the problem is in the code or where?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|