Determin if a binary file is encrypted

T

TheLostLeaf

Hi,

I wote some code that encrypts binary files, and decrypts them, works
great. It uses the same file name, so if the file is called
mountain.jpg, it encrypts it with the same name.

I'm using Rijndael, is there a script I can write that can tell if the
file is encrypted before i try to read it into a picturebox or
something.

One way i can tell is it error on load as not a valid image, but i
want to be able to do it with all files.

Thanks !
 
A

Arne Vajhøj

TheLostLeaf said:
I wote some code that encrypts binary files, and decrypts them, works
great. It uses the same file name, so if the file is called
mountain.jpg, it encrypts it with the same name.

I'm using Rijndael, is there a script I can write that can tell if the
file is encrypted before i try to read it into a picturebox or
something.

One way i can tell is it error on load as not a valid image, but i
want to be able to do it with all files.

In general: no. There is nothing preventing that the same file
can be both an encrypted file and an image. So you can not
distinguish.

If you are willing to limit yourself to a small set of
graphics formats, then you can check if the file matches
a header for that file type (magic value and other known
values).

Arne
 
T

TheLostLeaf

In general: no. There is nothing preventing that the same file
can be both an encrypted file and an image. So you can not
distinguish.

If you are willing to limit yourself to a small set of
graphics formats, then you can check if the file matches
a header for that file type (magic value and other known
values).

Arne

Thanks, I think i will rename the file with an extra extention, like
mountain.jpg.enc. I didn't know if I could same the BOF or EOF for a
tell take char that might occur with any Rijndael encrypt.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top