我有在编码串,并返回URL安全字符串C#的一段代码(即解码以后)C#等效的base64 + UrlTokenEncode的Clojure中
string stringToEncrypt = "Winter is coming";
byte[] bytes = new byte[stringToEncrypt.Length * sizeof(char)];
System.Buffer.BlockCopy(stringToEncrypt.ToCharArray(), 0, bytes, 0, bytes.Length);
System.Web.HttpServerUtility.UrlTokenEncode(bytes).Dump();
Dump
是从LinqPad。我用它来快速测试C#的代码片段
执行时返回VwBpAG4AdABlAHIAIABpAHMAIABjAG8AbQBpAG4AZwA1
。
我正试图从clojure服务做同样的事情。使用encode
库和this answer去当我有
(String. (b64/encode (.getBytes email)) "UTF-8")
我得到V2ludGVyIGlzIGNvbWluZw==
,这是
- 没有URL编码
- 不匹配的C#版本。
尝试查看UrlTokenEncode()
的MSDN文档,但没有太多的细节介绍它的实现,以便查看底层发生了什么。
我可以在clojure中生成等效字符串吗?
你可以找到UrlTokenEncode [这里](HTTP的源代码:/ /www.dotnetframework.org/default.aspx/[email protected]@1/[email protected]@1/[email protected]@1/DEVDIV/depot/DevDiv/releases/whidbey/NetFXspW7/ndp/fx/src/xsp/System/Web/httpserverutility @ cs/1/httpserverutility @ cs) – 2014-12-01 18:49:10
Ack。不知道为什么链接不工作。做一个谷歌搜索urltokenencode源,并点击dotnetframework.org链接。 – 2014-12-01 18:55:52
@罗伯特哈维酷啊,当然,我当时看错了地方!谢谢。 – LocustHorde 2014-12-02 09:57:07