Base64 Encoding safe for filenames?

后端 未结 6 1745
一生所求
一生所求 2020-12-28 14:01

Is Base64 encoding safe to use for filenames on Windows and Linux systems? From my research I have found that replacing all / characters of the result with

6条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-28 14:43

    A filename created by Base64 is only safe if you use a different character from /, which you do, as NTFS does not allow that character to be used in file names. As long as you do that, pretty much all commonly used file systems in common use will be OK.

    However, if the filesystem is case-insensitive, as is the case on Windows, you can get collisions because the Base64 alphabet contains both upper and lower-case.

    You might want to consider using the hexadecimal representation of your MD5 hash instead, since this is a fairly standard way of representing those as a string.

提交回复
热议问题