Alex Lee
Alex Lee

Reputation: 1

How to encrypt file name on upload and decrypt on download?

Made an ASP.NET web application which receives a file using file upload control and then encrypts file name on upload.

But when I redirect a user to file_address (so this user can download the file) I don't know how can i decrypt the file name now? because a file (for example a .docx file) doesn't have code behind.

So when the user downloads the file He/She receives a file with encrypted name!

All files in the server have a encrypted name and not their original name And What i want to know is how to give files their original name when users download files

Upvotes: 0

Views: 1463

Answers (1)

Shannon Holsinger
Shannon Holsinger

Reputation: 2341

You can't give the user a direct link to the file - rather a page that first decrypts the file, then writes appropriate response headers and sends the decrypted file as a response.

Like getFile.aspx?encryptedFileName=abcxyz. In Init, getfile.aspx loads the encrypted file, decrypts it, then writes appropriate response headers for the file, changing MIME type to whatever the file requires, and sending the decrypted file instead of a web page.

Here's an example of how to do this with a ZIP file. If you need more help after looking at this, let me know. How do I generate and send a .zip file to a user in C# ASP.NET?

Upvotes: 2

Related Questions