Created
August 28, 2020 19:33
-
-
Save adrianokerber/28e2493e9d77ef23752c78912d6209b7 to your computer and use it in GitHub Desktop.
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
using System; | |
using System.Text; | |
namespace AdrianoKerber.Converter | |
{ | |
public static class Base64Converter | |
{ | |
public static string FromStringToBase64(string stringValue) | |
{ | |
if (string.IsNullOrWhiteSpace(stringValue)) | |
return null; | |
byte[] stringAsByteArray = Encoding.ASCII.GetBytes(stringValue); | |
string base64Value = Convert.ToBase64String(stringAsByteArray); | |
return base64Value; | |
} | |
public static string FromBase64ToString(string base64Value) | |
{ | |
if (string.IsNullOrWhiteSpace(base64Value)) | |
return null; | |
byte[] base64AsByteArray = Convert.FromBase64String(base64Value); | |
string plainTextString = Encoding.ASCII.GetString(base64AsByteArray); | |
return plainTextString; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment