Skip to main content
New
Stack Overflow Jobs powered by Indeed: A job site that puts thousands of tech jobs at your fingertips (U.S. only). Search jobs
70 votes
Accepted

Can a large file be hashed down to 32 bytes, and then reconstructed from the hash?

No, there is no way to compress (or hash or encrypt or whatever) a 5 MB file into a 32 byte hash and then reconstruct the original file just from the hash alone. This is simply because there are many ...
Ilmari Karonen's user avatar
34 votes

Why is the output of a True Random Number Generator (TRNG) insecure after it has been compressed?

I think you're misinterpreting the source. The source says the TRNGs "rely" on compression (a cryptographic hash would be the compression function, or possibly some simpler function to ...
Serpent27's user avatar
  • 1,461
25 votes

Is it better to encrypt before compression or vice versa?

Neither: Encrypting first and then compressing does not work. Compressing first can leak information about plaintext content through the ciphertext length, as poncho mentioned in comments to another ...
otus's user avatar
  • 32.1k
23 votes

Encoding vs. Compression vs. Encryption

OK, there seems to be some confusion with regards to terminology, so let's try to clean that up. I'll try and define things myself, but also provide the more formal Wikipedia definitions. Encryption. ...
SEJPM's user avatar
  • 46.1k
21 votes

Can one use a reversible hash algorithm as a compression function?

Strictly speaking, all hash functions are compressing since the output can be smaller than the input, but I imagine you're asking about compressing data that can later be losslessly decompressed. This ...
forest's user avatar
  • 15.3k
19 votes

Can a large file be hashed down to 32 bytes, and then reconstructed from the hash?

No, it's not possible to retrieve the original input of a hash, because the input of a hash can be of almost any size (less than 2'091'752 terabytes). But the hash value is always a fixed length, i.e....
AleksanderCH's user avatar
  • 6,462
19 votes

Is the decompression of compressed and encrypted data without decryption also theoretically impossible?

The decompression of compressed-then-encrypted data is not possible without the decryption key, at least for compression and encryption schemes independent of each other. We can make a theoretical ...
fgrieu's user avatar
  • 142k
11 votes

Can one use a reversible hash algorithm as a compression function?

If the question was about (current form) Reversible cryptographic hash functions Then No! One-wayness property of the cryptographic secure hash functions will prevent that. Hash functions don't use ...
kelalaka's user avatar
  • 48.7k
9 votes

Is the decompression of compressed and encrypted data without decryption also theoretically impossible?

You say you want to decompress the data coming from A so B can do incremental backups and recovery. Were A's data not encrypted this would make perfect sense. But A's data is encrypted and that ...
Schwern's user avatar
  • 461
8 votes
Accepted

Is it possible to compress a random sequence with high entropy?

Random data can not be compressed. Good pseudo random data can not be compressed(with generic algorithm). As Paul commented if you use an inefficient encoding such as hexadecimal or Decimal ASCII ...
Meir Maor's user avatar
  • 11.8k
7 votes

Building blocks of SHA-1 and SHA-2

For each of the "MD" functions (MD4, MD5, SHA-1, SHA-256, SHA-512, and derivatives), one can view the compression function as a "tilted block cipher": the message block is used as key, and the ...
Thomas Pornin's user avatar
7 votes
Accepted

Is it ever safe to use encryption with compression?

I think that the answer to this question is a bit more involved than it first seems. The reason is that the compression attacks work when different lengths after compression reveal information about ...
Yehuda Lindell's user avatar
7 votes

Is the decompression of compressed and encrypted data without decryption also theoretically impossible?

I think it is theoretically possible to have semantically secure encryption that supports decompression of encrypted data (both in lossy and lossless compression settings), but that it will be very ...
Polytropos's user avatar
6 votes
Accepted

Compression-Ratio Side Channel

Here's the basic idea. Encryption ideally hides all information about the encrypted data. But in practice, that isn't completely true: encryption reveals the size of the encrypted data, at least ...
Gilles 'SO- stop being evil''s user avatar
6 votes

Are there any algorithms or alternatives to create short signatures?

Are there any algorithms or alternatives to create short signatures. The algorithm does not have neccessarily have to rely on public/private key. Both parties are ment to be secure and can use the ...
poncho's user avatar
  • 148k
6 votes

Can a large file be hashed down to 32 bytes, and then reconstructed from the hash?

The other answers are correct, there is no way to recover data from a hash. From your phrasing, I think that this may be an instance of an X-Y problem: you need very aggressive lossless compression, ...
cakins's user avatar
  • 69
6 votes
Accepted

How reassuring is CRC-then-XTS as authenticated encryption?

No, this does not make a deterministic authenticated cipher, unless you're using a secret CRC as a MAC. How do you break it? First, find a pair of messages $m = m_1 \mathbin\| m_2$ and $m' = m'_1 \...
Squeamish Ossifrage's user avatar
6 votes
Accepted

What is the difference between data compression and compression in cryptographic algorithms?

In data lossless compression we want the data recoverable from the compressed form. This is usually helpful if the entropy is low like text files, so-called zipping. In data lossy compression like ...
kelalaka's user avatar
  • 48.7k
5 votes

Decrypting two XORed compressed messages?

Update: a premise in the former answer did not resist the acid test of experiment. This whole answer was thus very wrong. Thanks to daniel's comment for opening my eyes.
fgrieu's user avatar
  • 142k
5 votes

What are the differences between Encrypt+Compress and Compress+Encrypt a.When and where do we use them, explain it in a scenario

Attempting to compress encrypted data will generally fail: It's impossible to compress high-entropy (random) data, and encrypted data is typically indistinguishable from random data. (The actual ...
SAI Peregrinus's user avatar
5 votes

Is it better to encrypt before compression or vice versa?

Make sure to also check out the CRIME and BREACH attacks, which are made possible by protocols using compression inside encryption.
Ivo's user avatar
  • 231
5 votes

Can a large file be hashed down to 32 bytes, and then reconstructed from the hash?

Simple information theory shows that this is not possible. For any given hash value, there's an infinite number of files that produce that hash (assuming there's no arbitrary limit on the input ...
Toby Speight's user avatar
5 votes
Accepted

Can I compress $192$ byte key into $16$ or $32$ bytes which can be later used in KDF to recover full key

No, there is no way (secure or otherwise) to compress a random $192$ byte value into something smaller; it is impossible to encode $2^{8 \times 192}$ bit possible settings in only 32 bytes (or $191$ ...
poncho's user avatar
  • 148k
4 votes

Can you compress an elliptic curve private key in half?

This isn't the direction you were thinking of, however I believe that this is an answer to the question you meant to ask: According to this, a $n$-bit key offers about $n/2$ bits of security. That ...
poncho's user avatar
  • 148k
4 votes

Can compressed data be made to look like random data?

TL;DR: yes it can look more random than the plaintext message itself, but it won't help you against crypt-analysis and in the worst case it may introduce vulnerabilities. I guess the most boring but ...
Maarten Bodewes's user avatar
4 votes
Accepted

Entropy Preserving Functions

Of course not; 8 bits have a maximum of 8 bits of entropy. There does not exist a probability distribution over the 256 possible values of those 8 bits that gives an entropy value of more than 8. ...
poncho's user avatar
  • 148k
4 votes

In a PGP like Application , would compress and encrypt leak information

Compression before encryption can leak information in a few ways. Compression occurs on the plaintext, encryption is on the result of compression, and then there's a public and quite precise relation ...
fgrieu's user avatar
  • 142k
4 votes
Accepted

Would compressing encrypted data and compressing digital signatures be bad for security?

Applying lossless compression (like LZMA) to a database with encrypted or/and signed data is mostly neutral from a security standpoint: it's neither good, nor necessarily bad (but see second point ...
fgrieu's user avatar
  • 142k
3 votes

Is it possible to compress a random sequence with high entropy?

My question is whether compressing the generated file is a proper test? Does the algorithm fail because of the generated file can be compressed? Yes. No. You've misinterpreted a small but crucial ...
Paul Uszak's user avatar
  • 15.5k
3 votes
Accepted

Is TLS 1.2 compression methods in client_hello a mandatory field?

Well, it is specified in the ClientHello struct here, and the description reads: The ClientHello includes a list of compression ...
Maarten Bodewes's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible