问题描述
我按在C#中寻找一个(快)标准实现base64url 。
我发现<一个href=\"http://msdn.microsoft.com/en-us/library/system.web.httpserverutility.urltokenen$c$c(v=vs.110).aspx\"相对=nofollow> HttpServerUtility.UrlTokenEn code
但看起来这并不遵循RFC4648(UrlTokenEn code。在增加了许多这表明的 =
被拆除的迹象号结束;见和<一个href=\"http://stackoverflow.com/questions/7448683/en$c$c-url-from-c-decrypt-url-in-php-extra-characters-being-added-somehow\">here).
例如:
base64编码:
base64url encoding:
Based on the comments, it sounds like HttpServerUtility.UrlTokenEncode
does the right thing except for the extra character for padding. So you should be able to do:
string customBase64 = HttpServerUtility.UrlTokenEncode(data);
string rfc4648 = customBase64.Substring(0, customBase64.Length - 1);
However, you should add unit tests to check that it really does use the RFC 4648 alphabet (and in the same way as RFC 4648). It's somewhat surprising that the docs are so sparse :(
这篇关于C#:base64url根据RFC4648的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!