Format of AES, Blowfish, Twofish, 3DES, etc. Symmetric Encrypted Data?
I know it isn’t listed in the documentation, but is there any method to test whether a file has been previously encrypted or not? I would like to perform decryption on a file, but only if it is already encrypted.
A symmetric encryption algorithm is simply a transformation of bytes such that the output has the properties of randomly generated byte data. There is no file format, and each byte value from 0x00 to 0xFF is virtually equally probable.
There is no single test that can be performed to determine if a file is already encrypted. There are two solutions:
- Create your own test based on the type of file being encrypted. For example, if XML files are encrypted, then test to see if “<xml” is found in the beginning.
- Create your own simple “encrytped file format”. For example, it could be as easy as writing a 4-byte “marker” at the beginning of every file containing encrypted data. The marker would be a constant value, such as 0x01020304. Your application could read the 1st 4 bytes of a file, and if equal to 0x01, 0x02, 0x03, 0x04, then it discards the marker and knows the remainder is the encrypted file data..