What is the difference between Convert.ToBase64String(byte[]) and HttpServerUtility.UrlTokenEncode(byte[])?
我正在尝试从Web API项目中删除对
Encodes a byte array into its equivalent string representation using base 64 digits, which is usable for transmission on the URL.
我尝试用
Converts an array of 8-bit unsigned integers to its equivalent string representation that is encoded with base-64 digits.
但是,它们似乎并不完全相同。 当使用
The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters.
这两个转换实用程序有什么区别? 消除对
一些用户建议这是此副本的副本,但我不同意。 这个问题是关于通常以url安全的方式对字符串进行base-64编码的,但是我需要重现
我以DGibbs的话为准,并使用了Source。事实证明,在
编码为Base64
使用
将
替换字符串末尾的任意数量的
从Base64解码
用相同数量的
将
使用
通常,将'+'替换为'-',将'/'替换为'_',仅删除'='。
这里接受的答案给出了一个代码示例:如何在C#中实现Base64 URL安全编码?