1

I am looking for if it's possible to losslessly recreate the original content of a text file only from a stored hash value (I prefer CRC checksum algorithm instead of others, because it's footprint is really small, although it can be considered BAD for large inputs).

Specifically, I have one text file consisting of 16 characters from the alphabet:

AD
DE
CB
ME
AE
PA
EB
AB
CN
NO
CE
MD
CK
GI
CL
GL
LE
CA
PH
GE
HB
CL
DE
CA
LF
CK
KD
CB
AB
BJ
JA
KE
KL
GI
HM
CI
DB
DE
AJ
FC

Goal: restore the original file content losslessly only from CRC hash values

My questions:

  1. If you have a suitably small and finite set of files, that just coincidentally have unique hashes, then yes you can derive the file from the hash, using the hash as a key.

    1.1 - Small input - what´s the limit of overall number of characters in text file when hash algorithm still considers the file as good in term of making hash collisions?

    P.S. Of course, separator (newline in this case) can be removed, since there are only two values (one pair), but that´s irrelevant so far. Therefore it can be mixed together, yet it must be paired correspondingly - i.e. "ADDECBME"

  2. To guarantee that hash collisions do not occur for your "library" of files, you can reserve a "scratch area" (a gap somewhere) for tie breaking purposes and populate it with arbitrary values that produce a new, unique key for the whole file, which has now changed.

    2.1. "Scratch area" - could it be defined in the form of new folders? I mean: there will be folders from 1-2000 with many generated files for CRC checksum comparisons purposes.

    Or it must be separated much better such as corrupt file strategy? Corrupted files always gives the 00000000 CRC value (I know that from WinRAR), so... or 1st approach is better?

  3. As for files generation, files will be generated randomly according to given specification since they don´t contain followable pattern at all. Any better ideas? Remember that I want to preserve only the CRC values, nothing more.

Time is not important, of course.

Could you help me?

closed as too broad by DavidPostill Dec 13 '18 at 20:51

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • It cannot be done. Consider this: while unlikely, multiple unique files can produce identical hashes. Because of this, it's impossible to take a hash and turn it into one unique file. – Twisty Impersonator Dec 13 '18 at 21:51
  • @TwistyImpersonator - In principle you're right: there is no reverse of a many-to-one algorithm, but because of the constraints on the original data, it's possible that there may be a single solution if the length of the input is known, though I have no idea how to solve it other than by brute force. Without knowing a limit on the length, even with a limited character set, one can go on building up strings indefinitely until eventually the check-sum will be duplicated. – AFH Dec 13 '18 at 22:13
  • Here's an answer on Information Security that explains the reason behind my saying it's not possible. @AFH – Twisty Impersonator Dec 13 '18 at 22:18
  • But this question shouldn't be on hold. It's most definitely answerable. – Twisty Impersonator Dec 13 '18 at 22:23
  • @TwistyImpersonator - I said there might be only one solution under certain constraints. To expand the analogy in your link, x%4=3 has no unique solution, but the additional constraint that x is a prime between 20 and 30 would mean that there is a unique answer. In the questioner's case, there may be a single answer within the questioner's constraints and my length limitation, but this can't be guaranteed, and there is no algorithm to determine it, other than brute force (which would need up to 16^80 or ~2*10^98 passes with the questioner's 40 two character lines). – AFH Dec 13 '18 at 22:48

Browse other questions tagged or ask your own question.