JsEncrypt.cs
1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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;
}
}
}