Reputation: 437
I want to check if file is encrypted or not , is there any better way to check if we can detect encrypted or not.
How can we detect that file is encrypted or not?
Upvotes: 1
Views: 1577
Reputation: 59263
Theoretically, you can't tell the difference between random data, encrypted data, and data that has been maximally compressed.
In real life, though, compressed and encrypted data are encoded in file formats with headers and other low-entropy regions that you can use to recognize them.
A pretty good implementation would be to look for a whole bunch of tags that you know, and then use a rule of thumb:
Also, the overall entropy of compressed data, if you measure it with bigrams or trigrams, will not be as high as encrypted data, because compression is never perfect.
Upvotes: 1