mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-09-19 10:08:04 +08:00
全面修改Id为Guid类型,为2.0版做准备
This commit is contained in:
59
Infrastructure/Encryption.cs
Normal file
59
Infrastructure/Encryption.cs
Normal file
@@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
namespace Infrastructure
|
||||
{
|
||||
public class Encryption
|
||||
{
|
||||
private static string encryptKey = "4h!@w$rng,i#$@x1%)5^3(7*5P31/Ee0";
|
||||
|
||||
//默认密钥向量
|
||||
private static byte[] Keys = { 0x41, 0x72, 0x65, 0x79, 0x6F, 0x75, 0x6D, 0x79, 0x53, 0x6E, 0x6F, 0x77, 0x6D, 0x61, 0x6E, 0x3F };
|
||||
/// <summary>
|
||||
/// 加密
|
||||
/// </summary>
|
||||
/// <param name="encryptString"></param>
|
||||
/// <returns></returns>
|
||||
public static string Encrypt(string encryptString)
|
||||
{
|
||||
if (string.IsNullOrEmpty(encryptString))
|
||||
return string.Empty;
|
||||
RijndaelManaged rijndaelProvider = new RijndaelManaged();
|
||||
rijndaelProvider.Key = Encoding.UTF8.GetBytes(encryptKey.Substring(0, 32));
|
||||
rijndaelProvider.IV = Keys;
|
||||
ICryptoTransform rijndaelEncrypt = rijndaelProvider.CreateEncryptor();
|
||||
|
||||
byte[] inputData = Encoding.UTF8.GetBytes(encryptString);
|
||||
byte[] encryptedData = rijndaelEncrypt.TransformFinalBlock(inputData, 0, inputData.Length);
|
||||
|
||||
return Convert.ToBase64String(encryptedData);
|
||||
}
|
||||
/// <summary>
|
||||
/// 解密
|
||||
/// </summary>
|
||||
/// <param name="decryptString"></param>
|
||||
/// <returns></returns>
|
||||
public static string Decrypt(string decryptString)
|
||||
{
|
||||
if (string.IsNullOrEmpty(decryptString))
|
||||
return string.Empty;
|
||||
try
|
||||
{
|
||||
RijndaelManaged rijndaelProvider = new RijndaelManaged();
|
||||
rijndaelProvider.Key = Encoding.UTF8.GetBytes(encryptKey.Substring(0, 32));
|
||||
rijndaelProvider.IV = Keys;
|
||||
ICryptoTransform rijndaelDecrypt = rijndaelProvider.CreateDecryptor();
|
||||
|
||||
byte[] inputData = Convert.FromBase64String(decryptString);
|
||||
byte[] decryptedData = rijndaelDecrypt.TransformFinalBlock(inputData, 0, inputData.Length);
|
||||
|
||||
return Encoding.UTF8.GetString(decryptedData);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -91,6 +91,7 @@
|
||||
<Compile Include="Filter.cs" />
|
||||
<Compile Include="GenerateId.cs" />
|
||||
<Compile Include="HttpHelper.cs" />
|
||||
<Compile Include="JQData.cs" />
|
||||
<Compile Include="JsonConverter.cs" />
|
||||
<Compile Include="JsonHelper.cs" />
|
||||
<Compile Include="LogHelper.cs" />
|
||||
|
39
Infrastructure/JQData.cs
Normal file
39
Infrastructure/JQData.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : FundationAdmin
|
||||
// Author : yubaolee
|
||||
// Created : 03-09-2016
|
||||
//
|
||||
// Last Modified By : yubaolee
|
||||
// Last Modified On : 03-09-2016
|
||||
// ***********************************************************************
|
||||
// <copyright file="JqData.cs" company="Microsoft">
|
||||
// 版权所有(C) Microsoft 2015
|
||||
// </copyright>
|
||||
// <summary>jqGrid的数据格式</summary>
|
||||
// ***********************************************************************
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Entity
|
||||
{
|
||||
/// <summary>
|
||||
/// jqGrid的返回值
|
||||
/// </summary>
|
||||
public class JqData
|
||||
{
|
||||
/// <summary>
|
||||
/// 页码
|
||||
/// </summary>
|
||||
public int page;
|
||||
/// <summary>
|
||||
/// 总页数
|
||||
/// </summary>
|
||||
public int total;
|
||||
/// <summary>
|
||||
/// 总记录条数
|
||||
/// </summary>
|
||||
public int records;
|
||||
|
||||
public IEnumerable<object> rows;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user