Reputation: 627
I have to encrypt file names and folder names. The challenge is that the encrypted name string can have invalid characters for file name if I use AES 256 encryption. Do you have any suggestions how to handle this? Is this the right way to do file name encryption?
Upvotes: 1
Views: 622
Reputation: 162722
The answer varies depending on how far you want to take this; the suggesting of encrypting the file names and then running the encrypted result through a base64 encoder is a solid suggestion.
Alternatively, you might consider simply using UUIDs for all filenames and then have an (encrypted) data file that maps between UUID and what the file contains in the context of your application.
You won't be able to control the names given to system generated files; cache entries, defaults, etc...
Overall, encrypting the filenames is a bit futile. If the contents are encrypted, the names don't really matter and you are free to choose names that are meaningful while remaining confidential (i.e. code names). If the contents aren't encrypted, then vague / meaningless filenames aren't much good anyway.
Upvotes: 6