如何在iOS中加密文件名和文件夹名?

时间:2022-11-03 04:32:19

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?

我必须加密文件名和文件夹名称。挑战在于,如果我使用AES 256加密,加密的名称字符串可能包含无效的文件名字符。你对此有何建议?这是进行文件名加密的正确方法吗?

1 个解决方案

#1


6  

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.

答案取决于您想要走多远;建议加密文件名然后通过base64编码器运行加密结果是一个坚实的建议。

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.

或者,您可以考虑简单地将UUID用于所有文件名,然后使用(加密)数据文件在UUID和应用程序上下文中包含的文件之间进行映射。

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.

总的来说,加密文件名有点徒劳。如果内容是加密的,名称并不重要,您可以*选择有意义的名称,同时保持机密(即代码名称)。如果内容没有加密,那么模糊/无意义的文件名无论如何都不是很好。

#1


6  

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.

答案取决于您想要走多远;建议加密文件名然后通过base64编码器运行加密结果是一个坚实的建议。

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.

或者,您可以考虑简单地将UUID用于所有文件名,然后使用(加密)数据文件在UUID和应用程序上下文中包含的文件之间进行映射。

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.

总的来说,加密文件名有点徒劳。如果内容是加密的,名称并不重要,您可以*选择有意义的名称,同时保持机密(即代码名称)。如果内容没有加密,那么模糊/无意义的文件名无论如何都不是很好。