简体   繁体   中英

How to maintain encrypted file content-type?

I am written an algorithm to encrypt and decrypt file using AES.

I am also changing the encrypted file extension to .fenc .

So now the problem is that I am not able to detect the content-type of the file because the file is encrypted and extension also changed.

I am planning to do this: in the encrypted file into the first line I will put the content-type details and after that the encrypted data. And while decrypting the file I will read the first line and after that decrypted the content.

What do you think about this?

Why don't you just add .fenc to the filename, eg mymasterplan.ppt.fenc ? That way you can determine the content type based on the filename.

I think this could work but I suggest that you store the content type too in an encrypted way. This maybe different from the rest of the files encryption. from your question it seems as if the encryption key depends on the content type.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM