Click here to Skip to main content
15,884,859 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I'm already able to generate a hash based on a string of text. But I want to split the text in someones file and try to determine the type of hash, what would be the method to find this.

MSDN Only shows how to verify a hash by comparison, but not by identifying what type of hash it is. Tried searching all night, gave up and went to bed.

Was looking for something similar to Online Hash ID but within MSDN
Posted
Updated 5-Dec-15 18:21pm
v8
Comments
Afzaal Ahmad Zeeshan 5-Dec-15 17:07pm    
The size of bytes generated can be checked against.
Herboren 5-Dec-15 18:44pm    
I knew I was on the right track under solution 1. Is there a specific way of doing this or do I just break the string up into a byte array and the count the elements?
Afzaal Ahmad Zeeshan 5-Dec-15 18:54pm    
The thing is that each hash type generates a special number of characters. I do not remember what is the actual size, but the string size for SHA256 will be less than SHA512 and SHA128 will be less than SHA256 and so on. So which means that they are generating string of different bytes.

I am sure you will find good support on MSDN. Consider reading the bytes generates and then compare the hash.
BillWoodruff 5-Dec-15 22:57pm    
"split the text" ... based on what criteria ?
Herboren 6-Dec-15 0:18am    
Im sorry, I used the wrong terminology. I meant break the hex string in bytes.

It's not possible to identify the hash algorithm used to generate a hash value. You have to have the original source code that generated the hash.
 
Share this answer
 
Comments
Herboren 5-Dec-15 17:55pm    
Im just windering, This guys application at Nirsoft is able to identify the hash values when importing a file containing hashes.

http://www.nirsoft.net/utils/hash_my_files.html

If that is the case, it he just counting the amount of bytes in the string to identify its type?
Sergey Alexandrovich Kryukov 5-Dec-15 19:20pm    
I have no idea what "to identify the hash values" can possibly mean. The page just calculates hash values from input data. This is not what you are asking in your original question. And "amount of bytes" has nothing to do with "type". The concept of "type" just does not exist.
—SA
Herboren 6-Dec-15 0:22am    
I've updated the question to make more sense.
Dave Kreskowiak 6-Dec-15 12:08pm    
That doesn't make anything any clearer.
What do you mean by "try to split the text" and "determine the type of hash"? You haven't defined either of these and until you do it's impossible to answer your question.

"Determine the type of hash" doesn't make any sense on it's own. You can only calculate a hash value for a given source, nothing more.
Dave Kreskowiak 5-Dec-15 19:39pm    
You don't "identify" a hash value. A hash value is calculated from the entire contents of the input, usually in bytes. In your case, the entire string.

MD5, SHA1 and CRC are three different hashing algorithms. They don't "identify" anything at all.
In addition to Solution 2. Not only it is impossible. I think some stronger statements are correct:

  1. There is no such concept as "hash type" or, say, "hash function type".
  2. The hypothetical ability to determine which function was used for generating a given hash value is not a requirement for a cryptographic hash function.
  3. The hypothetical ability to determine which function was used for generating a given hash value would contradict the requirements for a cryptographic hash function.

By the way, if one knows a particular function/algorithm which was used for calculation of the function value, this information should be useless for calculation of the original image in input of this function. This is the consequence from the requirements to a cryptographic hash function.

To understand it, you need to understand the notion of cryptographic hash function, its purpose, and requirements imposed on the algorithm: https://en.wikipedia.org/wiki/Cryptographic_hash_function[^].

According to this purpose, there are no such situations where the information on a particular cryptographic hash function used to produce some given hash value could possibly be useful. Such knowledge is only needed for the members of development team, to make sure that correct function is used — such candidates for such function have been broken and should never be used for cryptographic purposes.

[EDIT]

After looking at v.8 of the question I even wasted some time to "test" the "Online hash ID" "service". I have no idea what it was written for, but of course it does not "identity" the "hash type". I think this is a pure bogus. In response to hash, it simply list of hash function returning the hash of given size, all such functions known to the author. That's all the "secret".

—SA
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900