So, I have a file that is XY Exabytes big. I create a SHA-512 hash from it.
Are there any theoretical chances that I can retrieve the original data just from the sha512 hash?
Also, are there any better hashes then sha512?
Stack Exchange network consists of 181 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.Visit Stack Exchange
Cryptography Stack Exchange is a question and answer site for software developers, mathematicians and others interested in cryptography. It only takes a minute to sign up.Sign up to join this community
No, because a hash behaves (simply put) like a lossy compression function.
Meaning: you can use a hash like a sort of checksum, which enables you to identify and compare data. Using hashes, you can see if data has been modified (which, if re-hashed, would show a different hash as a result), or if two or more data packages are the same (every data package you hash will produce the same hash if the data is the same too).
But: you can not recreate the original data that was hashed. For that, you would need a (loss-less) compression function like you might know it from ZIP files.
So, no, you can not recreate the original data from it's hash. The only thing a hash is good for is to compare it with other hashes to see if the hashed data is identical or not.
To give you a real-world perspective on hashing data and your question about "extracting" the original data from a hash: expecting someone to be able to reproduce the original data from a hash, would be like asking someone to create a nice dinner for all of us while only having a receipt available.
The only option to try to recreate data that results in a predefined hash, would be to "brute-force" it with a trail-and-error approach where you create random data sets, hash those, and hope that they produce the same hash you've got. While such a brute-force method works with small data packages, it won't work for big data-sets as you describe them since it would take too long until you "by chance" happen to produce exactly the same data-set that once existed and which produced the originalhash. Good luck with that... you can safely expect to waste a life-time trying to get that one lucky match that fits a specific, predefined hash.
While I'm at it: it might be interesting for you to know that older and mostly broken hashes (MD2 etc) are known to have certain weaknesses that result in so-called "hash collisions". Such hashes are broken because those hash collisions mean nothing else than that two different data-sets produce the same hash, which should not happen as a hash is expected to produce a unique values for different data-sets. But that's just additional knowledge as hash collisions merely show the related hash fails it's job; they can not and will not help you recreate the data either. Why? Because a hash is something like an identification tag. It does not hold all the hashed data, and can therefore not reproduce it in any way.
Your wording is important: "retrieve the original data just from the sha512 hash" - the answer to that (strictly speaking) is no.
The best you can do is to try hashing a given number of possible byte-combinations (eg, the contents of the file) until you find an output that matches your original hash.
For a short byte-string, this attack is viable (this is why simply hashing a password and storing it in a database is not considered secure). However, brute-forcing an exabyte of data to find a corresponding hash is way too expensive to be considered realistic.
As for your other question - it's too subjective to answer. Suffice to say, sha512 is considered strong and you should feel confident using it.
The short answer is no.
The longer answer is that there may be an infinite number of matching plaintexts however finding one is expected to be very time consuming for a given hash.
Hash functions have several security criteria, one of which is called pre-image resistance. Pre-image resistance means that given an output hash value $h$ and hash function $H$, an input $m$ such that $h=H(m)$ cannot be computed efficiently.
SHA-512 is currently in good security standing. There are no practical pre-image attacks, which means that, no, the original data could not be calculated.
(As an aside, note that SHA-512 is 512 bits long. You cannot in general compress a string much longer than 512 bits to something less than 512 bits, so many, many messages will output the same hash. Even if SHA-512 were weak and gave information about the original message, at a minimum only partial information could be extracted since the attacker would have many potential strings mapping to $h$ and wouldn't know which was the original.)
The answer depends on what the XY Exabytes big data contains. If it contains very small amount of information, it may be possible for attacker to find the correct input by a trial. Maybe the XY exabytes of data is just some large 8K resolution video available from specific http://xxx.xx.xxx address or just full of zero bits, or ...
In case the XY Exabytes big data contains significant amount of information, then it'll be practically impossible for any attacker (with current knowledge) to be able to find the data matching the hash.
BTW, calculating SHA-512 hash of very large data takes substantial amount of time. SHA-512 hash does not allow calculating blocks in parallel, but each blocks needs to be calculated as a chain. To calculate SHA-512 hash of one exabyte takes somewhere around 100 years using a modern PC. (Expect somewhere around 300 Mbytes/second from quite good PC). Therefore, attacker equipped with modern PC is actually limited to trying calculating something based on recalculated results. Even attacker with custom hardware is likely going to have some issues with the amount of data to hash.
In fact so are you. How do you produce the hash for the large data in the first place? Expect it to take a while.
If you have data this large, the SHA-512 algorithm may be impractical for other reasons than security. The hash is very strong, but calculation will take long time. Maybe you'd like to use hash tree (using e.g. SHA-512 as hash function). Then the result will be different than using SHA-512 hash over the entire data, but the calculation can be parallelized to make the task practical again.
The SHA-512 is not compression function. But if the data exists somewhere (e.g. in the Internet or maybe hard disk of somebody else, or on a book), it is most likely easier to retrieve the data from the alternative source than recreate it from the hash, especially given that there are infinite number of other possible inputs of same size which give the same hash.