Add Custom encryption

This commit is contained in:
sunkaixuan
2022-03-11 18:17:41 +08:00
parent c3f4f4a36e
commit bf218a56a0
2 changed files with 20 additions and 0 deletions

View File

@@ -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; }
}
}

View File

@@ -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);