Base 64 String Encrypt and Decrypt - CSharp System

CSharp examples for System:String Base64

Description

Base 64 String Encrypt and Decrypt

Demo Code

using System;//from w  w  w  . j  ava 2s  . c o m
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SchoolPal_18Byte.Tools
{

    public class Base64Helper
    {

        public static string Base64Encrypt(string encryptStr, string encodeName = "utf-8")
        {
            return Convert.ToBase64String(Encoding.GetEncoding(encodeName).GetBytes(encryptStr));
        }

        public static string Base64Decrypt(string decryptStr, string encodeName = "utf-8")
        {
            return Encoding.GetEncoding(encodeName).GetString(Convert.FromBase64String(decryptStr));
        }

    }
}

Related Tutorials