Just wondering if a two-way fixed-length hash function exists. I'm not talking about encryption where your output is the same size if not larger than your input. I guess the best way I can put it is "like SHA or MD5, but also reversible." (I know SHA and MD5 aren't reversible by design, but you get the point).

  • $\begingroup$ Does it need to be reversible for everyone, or reversible in secret by few/one person? i.e. Are you looking for trapdoor one way functions? $\endgroup$
    – Ella Rose
    Aug 20, 2017 at 16:04
  • $\begingroup$ Well, it depends on the given secret. I'm working on a project where everything needs to be small, so say I want to turn a 512-character input into a 32-character hash. If I also needed to give 256 characters to reverse it, it still fits along the lines of my project's purpose, but not to the level I'd like. $\endgroup$ Aug 20, 2017 at 16:15
  • $\begingroup$ I am confused. What security objectives would such a function have and what of these functionalities is not fullfilled by taking a block cipher and fixing the key (or some other permutation)? $\endgroup$
    – SEJPM
    Aug 21, 2017 at 13:11

2 Answers 2


What I understood from your question is that you want to map your data uniquely such that the output has less bits relative to the input. You can use data compression techniques to compress your data. Then, if you need the security, use cryptography. Although hash functions are able to compress your data, but they can't be reversed by everyone. This goal is opposite of their nature and their duties.


No. This is answered by the pigeonhole principal. It is fundamentally hard to do.

The problem is, if you reduce the input into smaller numbers, it could be reversed back either into the message you want, or any other weird and meaningless number. 2274866217183956372711949572

Could reduce into 3726 theoretically, but from there it could be turned back into the above number, or a totally different one.

It's like burning up a log.

You're gonna get ash.

Theoretically, if you grab all the molecules and painstakingly reverse them, you would get the wood back.

But not without knowledge of what the wood looked like.

You could take all those molecules and reassemble them into something totally different, and that would also be possible.

So, in the end, this question's answer is yes, but only if you know a thing about the original message.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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