Last active
August 12, 2017 17:13
-
-
Save n3rd/58ef1f208fd2449c4fc3bf114c107e76 to your computer and use it in GitHub Desktop.
Base10ToBase64Url
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static string Base10ToBase64Url(ulong base10) | |
{ | |
char[] base64url = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".ToCharArray(); | |
var res = new List<char>(); | |
for (ulong remainder = base10, mod = remainder % 64; remainder > 0; remainder = remainder / 64, mod = remainder % 64) | |
{ | |
res.Add(base64url[mod]); | |
} | |
res.Reverse(); | |
return new String(res.ToArray()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment