JsEncrypt.cs 1.03 KB
using System;
using System.Collections.Generic;
using System.IO;
using System.Security.Cryptography;
using System.Text;

namespace Hh.Mes.Common
{
    /// <summary>
    /// 将客户端的加密数据进行解密  对应js文件 JsEncrypt.js
    /// </summary>
    public class JsEncrypt
    {
        // private property
        //public static string _keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";

        /// <summary>
        /// base64解密
        /// </summary>
        /// <param name="encode">编码,与js一致</param>
        /// <param name="result">加密源字符串</param>
        /// <returns></returns>
        public static string DecodeBase64(Encoding encode, string result)
        {
            string decode = "";
            byte[] bytes = Convert.FromBase64String(result);
            try
            {
                decode = encode.GetString(bytes);
            }
            catch
            {
                decode = result;
            }
            return decode;
        }
    }
}