增加PostgreSQL支持;

修复DES加密
This commit is contained in:
yubaolee
2023-02-16 21:45:01 +08:00
parent 3890aa3fba
commit e0c8c46c9b
12 changed files with 1724 additions and 89 deletions

View File

@@ -3,7 +3,7 @@
public static class Define
{
public static string USERROLE = "UserRole"; //用户角色关联KEY
public const string ROLERESOURCE= "RoleResource"; //角色资源关联KEY
public const string ROLERESOURCE = "RoleResource"; //角色资源关联KEY
public const string USERORG = "UserOrg"; //用户机构关联KEY
public const string ROLEELEMENT = "RoleElement"; //角色菜单关联KEY
public const string ROLEMODULE = "RoleModule"; //角色模块关联KEY
@@ -11,6 +11,7 @@
public const string DBTYPE_SQLSERVER = "SqlServer"; //sql server
public const string DBTYPE_MYSQL = "MySql"; //mysql
public const string DBTYPE_PostgreSQL = "PostgreSQL"; //PostgreSQL
public const string DBTYPE_ORACLE = "Oracle"; //oracle

View File

@@ -7,14 +7,13 @@ namespace Infrastructure.Extensions
{
public static class SecurityEncDecryptExtensions
{
private static byte[] Keys = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F };
/// <summary>
/// DES加密字符串
/// </summary>
/// <param name="encryptString">待加密的字符串</param>
/// <param name="encryptKey">加密密钥,要求为16位</param>
/// <returns>加密成功返回加密后的字符串,失败返回源串</returns>
/// <summary>
/// DES加密字符串
/// </summary>
/// <param name="encryptString">待加密的字符串</param>
/// <param name="encryptKey">加密密钥,要求为16位</param>
/// <returns>加密成功返回加密后的字符串,失败返回源串</returns>
public static string EncryptDES(this string encryptString, string encryptKey)
{
@@ -24,7 +23,7 @@ namespace Infrastructure.Extensions
byte[] rgbIV = Keys;
byte[] inputByteArray = Encoding.UTF8.GetBytes(encryptString);
using (var DCSP = Aes.Create())
using (var DCSP = DES.Create())
{
using (MemoryStream mStream = new MemoryStream())
{
@@ -41,22 +40,21 @@ namespace Infrastructure.Extensions
{
throw new Exception("密码加密异常" + ex.Message);
}
}
/// <summary>
/// DES解密字符串
/// </summary>
/// <param name="decryptString">待解密的字符串</param>
/// <param name="decryptKey">解密密钥,要求为16位,和加密密钥相同</param>
/// <returns>解密成功返回解密后的字符串,失败返源串</returns>
/// <summary>
/// DES解密字符串
/// </summary>
/// <param name="decryptString">待解密的字符串</param>
/// <param name="decryptKey">解密密钥,要求为16位,和加密密钥相同</param>
/// <returns>解密成功返回解密后的字符串,失败返源串</returns>
public static string DecryptDES(this string decryptString, string decryptKey)
{
byte[] rgbKey = Encoding.UTF8.GetBytes(decryptKey.Substring(0, 16));
byte[] rgbIV = Keys;
byte[] inputByteArray = Convert.FromBase64String(decryptString.Replace('_', '+').Replace('~', '/'));
using (var DCSP = Aes.Create())
using (var DCSP = DES.Create())
{
using (MemoryStream mStream = new MemoryStream())
{
@@ -69,8 +67,8 @@ namespace Infrastructure.Extensions
}
}
}
}
public static bool TryDecryptDES(this string decryptString, string decryptKey, out string result)
{
result = "";
@@ -85,4 +83,4 @@ namespace Infrastructure.Extensions
}
}
}
}
}