mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-19 01:58:13 +08:00
Add Custom encryption
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace SqlSugar
|
||||
{
|
||||
public class StaticConfig
|
||||
{
|
||||
public static Func<string,string> Encode { get; set; }
|
||||
public static Func<string,string> Decode{ get; set; }
|
||||
}
|
||||
}
|
@@ -344,6 +344,10 @@ namespace SqlSugar
|
||||
|
||||
public static string EncodeBase64(string code)
|
||||
{
|
||||
if (StaticConfig.Encode != null)
|
||||
{
|
||||
return StaticConfig.Encode(code);
|
||||
}
|
||||
if (code.IsNullOrEmpty()) return code;
|
||||
string encode = "";
|
||||
byte[] bytes = Encoding.GetEncoding("utf-8").GetBytes(code);
|
||||
@@ -384,6 +388,10 @@ namespace SqlSugar
|
||||
{
|
||||
try
|
||||
{
|
||||
if (StaticConfig.Decode != null)
|
||||
{
|
||||
return StaticConfig.Decode(code);
|
||||
}
|
||||
if (code.IsNullOrEmpty()) return code;
|
||||
string decode = "";
|
||||
byte[] bytes = Convert.FromBase64String(code);
|
||||
|
Reference in New Issue
Block a user