Created
April 25, 2011 13:46
-
-
Save dmorrison/940532 to your computer and use it in GitHub Desktop.
C# string to byte[] to base 64 string back to original string
This file contains hidden or 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
var text = "foobar"; | |
var bytes = Encoding.Unicode.GetBytes(text); | |
var base64String = Convert.ToBase64String(bytes); | |
var sameBytes = Convert.FromBase64String(base64String); | |
var sameText = Encoding.Unicode.GetString(bytes); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment