Encrypting filename with file

D

dick

Hello,

I want to encrypt a file with its filename.
I can encrypt the file itself using the frame libraries.

How can I now best hide the filename and extension?
Within the file, ... ?

I must be able to retrieve the filename after decrypting.
The original files have random filenames and extensions.

example:

original file: username.sec
encrypted file with orig filename: username.sec
encrypted file with encrypted filename: mydate.dat

After encryption I must have username.sec again.

TIA
 
H

Herfried K. Wagner [MVP]

* "dick said:
I want to encrypt a file with its filename.
I can encrypt the file itself using the frame libraries.

How can I now best hide the filename and extension?
Within the file, ... ?

I must be able to retrieve the filename after decrypting.
The original files have random filenames and extensions.

example:

original file: username.sec
encrypted file with orig filename: username.sec
encrypted file with encrypted filename: mydate.dat

After encryption I must have username.sec again.

This would make encryption useless. The key used for
encrtyption/decryption is the most important part and storing it in a
format that can be easily read doesn't make much sense.
 
D

dick

Hello,

I don't mean storing the key, but the actual filename.

When the file is named "user.jpg", I want it saved as Enc1.dat or something
like that.
Later I must be able to retrieve the original filename from the encrypted
file, for restoring to the original file.
 
H

Herfried K. Wagner [MVP]

* "dick said:
I don't mean storing the key, but the actual filename.

OK, I misread your question, I thought you are using the filename as
encryption key. You can, for example, add sort of "header" to your file
that contains the file name. A very simple approach would be to store
the filename followed by a certain sequence of characters at the
beginning of the file. Then you will have to extract this data and pass
the rest of the file to your decryption routine.
 

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