45 lines
1.3 KiB
C#
45 lines
1.3 KiB
C#
namespace YLErp.Helpers
|
|
{
|
|
/// <summary>
|
|
/// 数据保护帮助类
|
|
/// </summary>
|
|
public static class DataProtectHelper
|
|
{
|
|
public static string Encrypt(int id)
|
|
{
|
|
return YieldChain.Security.DataProtect.Encrypt(id.ToString());
|
|
}
|
|
|
|
public static string Encrypt(string data)
|
|
{
|
|
return YieldChain.Security.DataProtect.Encrypt(data);
|
|
}
|
|
|
|
public static string Decrypt(string secretData)
|
|
{
|
|
return string.IsNullOrWhiteSpace(secretData) ? string.Empty : YieldChain.Security.DataProtect.Decrypt(secretData);
|
|
}
|
|
|
|
public static int DecryptInt(string secretData)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(secretData))
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
var data = YieldChain.Security.DataProtect.Decrypt(secretData);
|
|
return int.TryParse(data, out var nn) ? nn : 0;
|
|
}
|
|
public static long DecryptLong(string secretData)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(secretData))
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
var data = YieldChain.Security.DataProtect.Decrypt(secretData);
|
|
return long.TryParse(data, out var nn) ? nn : 0;
|
|
}
|
|
}
|
|
}
|