Base64

作者:追风剑情 发布于:2020-12-4 17:50 分类:C#

using System;
using System.Text;
/// <summary>
/// Base64加密解密
/// </summary>
public sealed class Base64
{
    /// <summary>
    /// 加密
    /// </summary>
    public static string Encode(string source)
    {
        byte[] bytes = Encoding.UTF8.GetBytes(source);
        string result = Convert.ToBase64String(bytes);
        return result;
    }

    /// <summary>
    /// 解密
    /// </summary>
    public static string Decode(string result)
    {
        byte[] bytes = Convert.FromBase64String(result);
        string source = Encoding.UTF8.GetString(bytes);
        return source;
    }
}

标签: C#

Powered by emlog  蜀ICP备18021003号-1   sitemap

川公网安备 51019002001593号