Created
February 1, 2012 08:24
-
-
Save tig/1715940 to your computer and use it in GitHub Desktop.
Base64 conversion
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 ToBase64(string encode) { | |
Byte[] btByteArray = null; | |
System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding(); | |
btByteArray = encoding.GetBytes(encode); | |
string sResult = System.Convert.ToBase64String(btByteArray, 0, btByteArray.Length); | |
sResult = sResult.Replace("+", "-").Replace("/", "_"); | |
return sResult; | |
} | |
public static string FromBase64(string decode) { | |
decode = decode.Replace("-", "+").Replace("_", "/"); | |
System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding(); | |
return encoding.GetString(Convert.FromBase64String(decode)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment