Skip to content

Instantly share code, notes, and snippets.

@angelobelchior
Created March 28, 2014 18:59
Show Gist options
  • Save angelobelchior/9840396 to your computer and use it in GitHub Desktop.
Save angelobelchior/9840396 to your computer and use it in GitHub Desktop.
using System;
using System.Text;
namespace Cryptography
{
public class Base64
{
public static string Encrypt(string text)
{
Throw.IfIsNullOrEmpty(text);
byte[] toEncodeAsBytes = ASCIIEncoding.ASCII.GetBytes(text);
string returnValue = Convert.ToBase64String(toEncodeAsBytes);
return returnValue;
}
public static string Decrypt(string text)
{
Throw.IfIsNullOrEmpty(text);
byte[] encodedDataAsBytes = Convert.FromBase64String(text);
string returnValue = ASCIIEncoding.ASCII.GetString(encodedDataAsBytes);
return returnValue;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment