Take the 2-minute tour ×
Cryptography Stack Exchange is a question and answer site for software developers, mathematicians and others interested in cryptography. It's 100% free, no registration required.

Is it possible to predict a hash key based on half key? Let's have some example:

I have 100000000 hash results, and they are generated by either

sha256( "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" . md5(random()) );


sha256( "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" . md5(random()) );

So, when someone generates a new hash (based on method "aa" ou method "bb"), is there any way that I can predict if hash is more a "aa" generated type or more a "bb" one?

I have already tried some type of Bayes classification, because I know that can only be there 2 types of results. But for each result I cannot classify hashes so that I have a good Bayes training.

Is this theoretically possible?

share|improve this question
A secure hash function, or even a not so great hash function, is not going to exhibit any of the properties you are looking for. –  GregS Feb 20 '12 at 18:08
thks greg. so, it's not possible to predict even if i know that half of key is "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" or "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" only? –  user1221679 Feb 20 '12 at 18:15
I dont know the answer, but I the security properties you are up against are : confusion (change 1 bit and about 50% of the bits change) and diffusion (change 1 bit and changes will be distributed evenly, given enough input). –  ixe013 Feb 20 '12 at 18:23
Welcome to Cryptography Stack Exchange. Your question was migrated here because of being not directly related to software development (the topic of Stack Overflow), and being fully on-topic here. Please register your account here, too, to be able to comment and accept an answer. –  Paŭlo Ebermann Feb 20 '12 at 20:02
add comment

migrated from stackoverflow.com Feb 20 '12 at 18:37

This question came from our site for professional and enthusiast programmers.

1 Answer

Somewhat simplified, if that were possible, you would have found a vulnerability in SHA-256. The kind of attack you're talking about is called a preimage attack, ie figuring out information on the original message from the hash. There have been some attacks of that kind against a weakened version of SHA-256 but no successful ones against the standard algorithm.

Of course your MD5 only adds 128 bits of entropy and your other data one (either all a or all b), but a brute force attack against 129 bits isn't what you're looking for either.

share|improve this answer
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.