mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-11-10 11:25:00 +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)
|
public static string EncodeBase64(string code)
|
||||||
{
|
{
|
||||||
|
if (StaticConfig.Encode != null)
|
||||||
|
{
|
||||||
|
return StaticConfig.Encode(code);
|
||||||
|
}
|
||||||
if (code.IsNullOrEmpty()) return code;
|
if (code.IsNullOrEmpty()) return code;
|
||||||
string encode = "";
|
string encode = "";
|
||||||
byte[] bytes = Encoding.GetEncoding("utf-8").GetBytes(code);
|
byte[] bytes = Encoding.GetEncoding("utf-8").GetBytes(code);
|
||||||
@@ -384,6 +388,10 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
if (StaticConfig.Decode != null)
|
||||||
|
{
|
||||||
|
return StaticConfig.Decode(code);
|
||||||
|
}
|
||||||
if (code.IsNullOrEmpty()) return code;
|
if (code.IsNullOrEmpty()) return code;
|
||||||
string decode = "";
|
string decode = "";
|
||||||
byte[] bytes = Convert.FromBase64String(code);
|
byte[] bytes = Convert.FromBase64String(code);
|
||||||
|
|||||||
Reference in New Issue
Block a user