I have a piece of code in C# that encodes string and returns URL safe string (that is decoded later on)
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
is from LinqPad. I use it to test bits and pieces of C# quickly
This Returns VwBpAG4AdABlAHIAIABpAHMAIABjAG8AbQBpAG4AZwA1
when Executed.
I am trying to do the same thing from a clojure service now. Using the encode
library and going by this answer When I have
(String. (b64/encode (.getBytes email)) "UTF-8")
I get V2ludGVyIGlzIGNvbWluZw==
, which is
- not url encoded
- doesn't match the C# version.
Tried looking at the MSDN documentation for UrlTokenEncode()
but it doesn't have much detail on the implementation of it to see what's going on under the hood.
Can I generate the equivalent string in clojure?