The title describes pretty well what I want to ask, because I just can't wrap my head around it. I understand the basics of breaking encrypted data with the method of kind-of-bruteforcing where you encrypt sample data then compare it to the encryption you want to crack. However I don't understand how cracking a sophisticated encryption works.
I will give this code I posted in another question, with risk because it wasn't accepted very well, but just to illustrate the simplest example
function my_hash($data){
// Generate random salt
$salt = substr(md5(str_shuffle('0123456789abcdef')), 0, 5);
// Mask salt within the hash
$hash = substr(md5($data. $salt), 0, -5) . $salt;
return $hash;
}
function my_check($data, $hash){
$salt = substr($hash, -5);
return substr(md5($data. $salt), 0, -5) . $salt === $hash;
}
$hash = my_hash('qwerty');
Can you explain to me, if you had a super-computer and billions of strings encrypted with that function, how could you find out the algorithm they were encrypted with?
Edit: The suggested question is not answering the one I asked, it is explaining how to guess the hashing function that was used, not how to crack it and find the algorithm behind it. I can easily say it is md5 when it's 32 bytes long and contains characters 0-9a-f but there's a difference between plain md5 and what I posted above.