I want to ensure that everyone who encrypts a given file gets the same encrypted file without knowing the password.

So, my idea was the following:

  1. hash the file
  2. encrypt the file (e.g. AES) with the hash
  3. publish it

Can this be done, if yes, is it secure?

The use case would be deduplication. Anonymity is not an issue.

closed as unclear what you're asking by Steffen Ullrich, Xander, forest, Teun Vink, Jeroen - IT Nerdbox Jan 6 at 9:24

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. 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.

  • 3
    You provide only a technical implementation (use file hash as key for encrypting the file) and the result of it (all owners of the file get the same result) but no actual use case for this. But to evaluate the security of your idea one actually needs a use case, i.e. in which context your idea should be applied and what are the security requirements of this use case. – Steffen Ullrich Dec 27 '18 at 14:46

Yes, it can be done. It has been used by some companies to allow deduplication of encrypted files. As in order to view the contents you need to know the hash, it is fine in principle (assuming you choose proper ciphers, hash, etc.)

However note that it allows metadata correlation. As the NSA, if these people all share the same file, even if I don't know what it is, I know they have the same contents. Similarly, if an entity suspects it may be infringing their copyright, using a consistent hashing means they could determine that a given file is what is being shared.

Not the answer you're looking for? Browse other questions tagged or ask your own question.