ソースを参照

修改加解密方法名,防止混淆后通过方法猜到方法直接引用调用

master
王晓寒 1ヶ月前
コミット
0880a50698
13個のファイルの変更207行の追加247行の削除
  1. +1
    -1
      SafeCampus.API/SafeCampus.Application/Services/Business/Warn/Service/WarnInfoService.cs
  2. +158
    -158
      SafeCampus.API/SafeCampus.Core/SafeCampus.Core.xml
  3. +9
    -9
      SafeCampus.API/SafeCampus.Core/Utils/Cryptogram/Q3J5cHRvZ3JhbVV0aWw.cs
  4. +2
    -12
      SafeCampus.API/SafeCampus.Core/Utils/Cryptogram/Sm/U000Q3J5cHRvVXRpbA.cs
  5. +2
    -12
      SafeCampus.API/SafeCampus.Core/Utils/Cryptogram/Sm/U00yQ3J5cHRvVXRpbA.cs
  6. +13
    -23
      SafeCampus.API/SafeCampus.Core/Utils/Cryptogram/U000VXRpbA.cs
  7. +4
    -14
      SafeCampus.API/SafeCampus.Core/Utils/Cryptogram/U00yVXRpbA.cs
  8. +1
    -1
      SafeCampus.API/SafeCampus.System/Services/Auth/Auth/AuthService.cs
  9. +7
    -7
      SafeCampus.API/SafeCampus.System/Services/Organization/User/SysUserService.cs
  10. +4
    -4
      SafeCampus.API/SafeCampus.System/Services/System/UserCenter/UserCenterService.cs
  11. +3
    -3
      SafeCampus.API/SafeCampus.Web.Core/Controllers/System/Auth/ActivateAuthController.cs
  12. +2
    -2
      SafeCampus.API/SafeCampus.Web.Core/Filter/SystemAuthorizeMiddleware.cs
  13. +1
    -1
      SafeCampus.API/SafeCampus.Web.Entry/appsettings.json

+ 1
- 1
SafeCampus.API/SafeCampus.Application/Services/Business/Warn/Service/WarnInfoService.cs ファイルの表示

@@ -106,7 +106,7 @@ public class WarnInfoService : DbRepository<WarnInfo>, IWarnInfoService, ITransi

//var issend = _simpleCacheService.Get<string>($"SMS_send{phone.SysUserItem.Phone}");
//if (issend != null) return true;
//var sendState = await _smsUtilService.SendSms(new[] { "+86" + CryptogramUtil.Sm4Decrypt(phone.SysUserItem.Phone) }, null);
//var sendState = await _smsUtilService.SendSms(new[] { "+86" + Q3J5cHRvZ3JhbVV0aWw.U200RGVjcnlwdA(phone.SysUserItem.Phone) }, null);
//if (sendState)
//{
// var configInterval = (await _configService.GetByConfigKey(CateGoryConst.CONFIG_BIZ_DEFINE,


+ 158
- 158
SafeCampus.API/SafeCampus.Core/SafeCampus.Core.xml ファイルの表示

@@ -1264,162 +1264,208 @@
</summary>
<returns></returns>
</member>
<member name="T:SafeCampus.Core.Utils.CryptogramUtil">
<member name="T:SafeCampus.Core.Utils.Q3J5cHRvZ3JhbVV0aWw">
<summary>
加解密功能
</summary>
</member>
<member name="M:SafeCampus.Core.Utils.CryptogramUtil.Sm2Decrypt(System.String)">
<member name="M:SafeCampus.Core.Utils.Q3J5cHRvZ3JhbVV0aWw.U20yRGVjcnlwdA(System.String)">
<summary>
SM2解密
</summary>
<param name="str">密文</param>
<returns>明文</returns>
</member>
<member name="M:SafeCampus.Core.Utils.CryptogramUtil.Sm2Encrypt(System.String)">
<member name="M:SafeCampus.Core.Utils.Q3J5cHRvZ3JhbVV0aWw.U20yRW5jcnlwdA(System.String)">
<summary>
SM2加密
</summary>
<param name="str">明文</param>
<returns>密文</returns>
</member>
<member name="M:SafeCampus.Core.Utils.CryptogramUtil.Sm4Decrypt(System.String)">
<member name="M:SafeCampus.Core.Utils.Q3J5cHRvZ3JhbVV0aWw.U200RGVjcnlwdA(System.String)">
<summary>
SM4解密
</summary>
<param name="str">密文</param>
<returns>明文</returns>
</member>
<member name="M:SafeCampus.Core.Utils.CryptogramUtil.Sm4Encrypt(System.String)">
<member name="M:SafeCampus.Core.Utils.Q3J5cHRvZ3JhbVV0aWw.U200RW5jcnlwdA(System.String)">
<summary>
SM4加密
</summary>
<param name="str">明文</param>
<returns>密文</returns>
</member>
<member name="T:SafeCampus.Core.Utils.SM2Util">
<member name="T:SafeCampus.Core.Utils.U000Q3J5cHRvVXRpbA">
<summary>
SM2加密解密
SM4工具类
</summary>
</member>
<member name="F:SafeCampus.Core.Utils.SM2Util.PublicKey">
<member name="M:SafeCampus.Core.Utils.U000Q3J5cHRvVXRpbA.GetULongByBe(System.Byte[],System.Int32)">
<summary>
公钥
加密 非线性τ函数B=τ(A)
</summary>
<param name="b"></param>
<param name="i"></param>
<returns></returns>
</member>
<member name="F:SafeCampus.Core.Utils.SM2Util.PrivateKey">
<member name="M:SafeCampus.Core.Utils.U000Q3J5cHRvVXRpbA.PutULongToBe(System.Int64,System.Byte[],System.Int32)">
<summary>
私钥
解密 非线性τ函数B=τ(A)
</summary>
<param name="n"></param>
<param name="b"></param>
<param name="i"></param>
</member>
<member name="M:SafeCampus.Core.Utils.SM2Util.Encrypt(System.String)">
<member name="M:SafeCampus.Core.Utils.U000Q3J5cHRvVXRpbA.Rotl(System.Int64,System.Int32)">
<summary>
公钥加密明文
循环移位,为32位的x循环左移n位
</summary>
<param name="plainText">明文</param>
<returns>密文</returns>
<param name="x"></param>
<param name="n"></param>
<returns></returns>
</member>
<member name="M:SafeCampus.Core.Utils.SM2Util.Decrypt(System.String)">
<member name="M:SafeCampus.Core.Utils.U000Q3J5cHRvVXRpbA.Swap(System.Int64[],System.Int32)">
<summary>
私钥解密密文
将密钥逆序
</summary>
<param name="cipherText">密文</param>
<returns>明文</returns>
<param name="sk"></param>
<param name="i"></param>
</member>
<member name="T:SafeCampus.Core.Utils.SM4Util">
<member name="F:SafeCampus.Core.Utils.U000Q3J5cHRvVXRpbA.SboxTable">
<summary>
Sm4算法
对标国际DES算法
S盒
</summary>
</member>
<member name="P:SafeCampus.Core.Utils.SM4Util.Data">
<member name="F:SafeCampus.Core.Utils.U000Q3J5cHRvVXRpbA.FK">
<summary>
数据
系统参数FK
</summary>
</member>
<member name="P:SafeCampus.Core.Utils.SM4Util.Key">
<member name="F:SafeCampus.Core.Utils.U000Q3J5cHRvVXRpbA.CK">
<summary>
秘钥
固定参数CK
</summary>
</member>
<member name="P:SafeCampus.Core.Utils.SM4Util.Iv">
<member name="M:SafeCampus.Core.Utils.U000Q3J5cHRvVXRpbA.Sm4Sbox(System.Byte)">
<summary>
向量
Sm4的S盒取值
</summary>
<param name="inch"></param>
<returns></returns>
</member>
<member name="P:SafeCampus.Core.Utils.SM4Util.HexString">
<member name="M:SafeCampus.Core.Utils.U000Q3J5cHRvVXRpbA.Sm4Lt(System.Int64)">
<summary>
明文是否是十六进制
线性变换 L
</summary>
<param name="ka"></param>
<returns></returns>
</member>
<member name="P:SafeCampus.Core.Utils.SM4Util.CryptoMode">
<member name="M:SafeCampus.Core.Utils.U000Q3J5cHRvVXRpbA.Sm4F(System.Int64,System.Int64,System.Int64,System.Int64,System.Int64)">
<summary>
加密模式(默认ECB)
统一改为ECB模式
轮函数 F
</summary>
<param name="x0"></param>
<param name="x1"></param>
<param name="x2"></param>
<param name="x3"></param>
<param name="rk"></param>
<returns></returns>
</member>
<member name="M:SafeCampus.Core.Utils.SM4Util.EncryptECB(SafeCampus.Core.Utils.SM4Util)">
<member name="M:SafeCampus.Core.Utils.U000Q3J5cHRvVXRpbA.Sm4CalciRk(System.Int64)">
<summary>
ECB加密
轮密钥rk
</summary>
<param name="entity"></param>
<param name="ka"></param>
<returns></returns>
</member>
<member name="M:SafeCampus.Core.Utils.SM4Util.EncryptCBC(SafeCampus.Core.Utils.SM4Util)">
<member name="M:SafeCampus.Core.Utils.U000Q3J5cHRvVXRpbA.SetKey(System.Int64[],System.Byte[])">
<summary>
CBC加密
加密密钥
</summary>
<param name="entity"></param>
<returns></returns>
<param name="SK"></param>
<param name="key"></param>
</member>
<member name="M:SafeCampus.Core.Utils.SM4Util.Decrypt(SafeCampus.Core.Utils.SM4Util)">
<member name="M:SafeCampus.Core.Utils.U000Q3J5cHRvVXRpbA.Sm4OneRound(System.Int64[],System.Byte[],System.Byte[])">
<summary>
解密
解密函数
</summary>
<param name="entity"></param>
<param name="sk">轮密钥</param>
<param name="input">输入分组的密文</param>
<param name="output">输出的对应的分组明文</param>
</member>
<member name="M:SafeCampus.Core.Utils.U000Q3J5cHRvVXRpbA.Padding(System.Byte[],System.Int32)">
<summary>
补足 16 进制字符串的 0 字符,返回不带 0x 的16进制字符串
</summary>
<param name="input"></param>
<param name="mode">1表示加密,0表示解密</param>
<returns></returns>
</member>
<member name="M:SafeCampus.Core.Utils.SM4Util.DecryptECB(SafeCampus.Core.Utils.SM4Util)">
<member name="M:SafeCampus.Core.Utils.U000Q3J5cHRvVXRpbA.SetKeyEnc(SafeCampus.Core.Utils.Sm4Context,System.Byte[])">
<summary>
ECB解密
设置加密的key
</summary>
<param name="entity"></param>
<param name="ctx"></param>
<param name="key"></param>
</member>
<member name="M:SafeCampus.Core.Utils.U000Q3J5cHRvVXRpbA.Sm4SetKeyDec(SafeCampus.Core.Utils.Sm4Context,System.Byte[])">
<summary>
设置解密的key
</summary>
<param name="ctx"></param>
<param name="key"></param>
</member>
<member name="M:SafeCampus.Core.Utils.U000Q3J5cHRvVXRpbA.Sm4CryptEcb(SafeCampus.Core.Utils.Sm4Context,System.Byte[])">
<summary>
ECB
</summary>
<param name="ctx"></param>
<param name="input"></param>
<returns></returns>
</member>
<member name="M:SafeCampus.Core.Utils.SM4Util.DecryptCBC(SafeCampus.Core.Utils.SM4Util)">
<member name="M:SafeCampus.Core.Utils.U000Q3J5cHRvVXRpbA.Sm4CryptCbc(SafeCampus.Core.Utils.Sm4Context,System.Byte[],System.Byte[])">
<summary>
CBC解密
CBC
</summary>
<param name="entity"></param>
<param name="ctx"></param>
<param name="iv"></param>
<param name="input"></param>
<returns></returns>
</member>
<member name="T:SafeCampus.Core.Utils.SM4Util.Sm4CryptoEnum">
<member name="T:SafeCampus.Core.Utils.Sm4Context">
<summary>
加密类型
SM4处理中心
</summary>
</member>
<member name="F:SafeCampus.Core.Utils.SM4Util.Sm4CryptoEnum.ECB">
<member name="F:SafeCampus.Core.Utils.Sm4Context.Mode">
<summary>
ECB(电码本模式)
1表示加密,0表示解密
</summary>
</member>
<member name="F:SafeCampus.Core.Utils.SM4Util.Sm4CryptoEnum.CBC">
<member name="F:SafeCampus.Core.Utils.Sm4Context.Key">
<summary>
CBC(密码分组链接模式)
密钥
</summary>
</member>
<member name="F:SafeCampus.Core.Utils.Sm4Context.IsPadding">
<summary>
是否补足16进制字符串
</summary>
</member>
<member name="T:SafeCampus.Core.Utils.SM2CryptoUtil">
<member name="T:SafeCampus.Core.Utils.U00yQ3J5cHRvVXRpbA">
<summary>
SM2工具类
</summary>
</member>
<member name="M:SafeCampus.Core.Utils.SM2CryptoUtil.GetKey">
<member name="M:SafeCampus.Core.Utils.U00yQ3J5cHRvVXRpbA.GetKey">
<summary>
获取公钥私钥
</summary>
<returns></returns>
</member>
<member name="M:SafeCampus.Core.Utils.SM2CryptoUtil.Encrypt(System.String,System.String)">
<member name="M:SafeCampus.Core.Utils.U00yQ3J5cHRvVXRpbA.Encrypt(System.String,System.String)">
<summary>
加密
</summary>
@@ -1427,7 +1473,7 @@
<param name="sourceData">需要加密的值</param>
<returns>加密结果</returns>
</member>
<member name="M:SafeCampus.Core.Utils.SM2CryptoUtil.Encrypt(System.Byte[],System.Byte[])">
<member name="M:SafeCampus.Core.Utils.U00yQ3J5cHRvVXRpbA.Encrypt(System.Byte[],System.Byte[])">
<summary>
加密
</summary>
@@ -1435,7 +1481,7 @@
<param name="data">需要加密的值</param>
<returns></returns>
</member>
<member name="M:SafeCampus.Core.Utils.SM2CryptoUtil.Decrypt(System.String,System.String)">
<member name="M:SafeCampus.Core.Utils.U00yQ3J5cHRvVXRpbA.Decrypt(System.String,System.String)">
<summary>
</summary>
@@ -1443,7 +1489,7 @@
<param name="encryptedData"></param>
<returns></returns>
</member>
<member name="M:SafeCampus.Core.Utils.SM2CryptoUtil.Decrypt(System.Byte[],System.Byte[])">
<member name="M:SafeCampus.Core.Utils.U00yQ3J5cHRvVXRpbA.Decrypt(System.Byte[],System.Byte[])">
<summary>
解密
</summary>
@@ -1451,172 +1497,126 @@
<param name="encryptedData"></param>
<returns></returns>
</member>
<member name="P:SafeCampus.Core.Utils.SM2CryptoUtil.SM2Model.PublicKey">
<member name="P:SafeCampus.Core.Utils.U00yQ3J5cHRvVXRpbA.SM2Model.PublicKey">
<summary>
公钥
</summary>
</member>
<member name="P:SafeCampus.Core.Utils.SM2CryptoUtil.SM2Model.PrivateKey">
<member name="P:SafeCampus.Core.Utils.U00yQ3J5cHRvVXRpbA.SM2Model.PrivateKey">
<summary>
私钥
</summary>
</member>
<member name="T:SafeCampus.Core.Utils.SM4CryptoUtil">
<summary>
SM4工具类
</summary>
</member>
<member name="M:SafeCampus.Core.Utils.SM4CryptoUtil.GetULongByBe(System.Byte[],System.Int32)">
<summary>
加密 非线性τ函数B=τ(A)
</summary>
<param name="b"></param>
<param name="i"></param>
<returns></returns>
</member>
<member name="M:SafeCampus.Core.Utils.SM4CryptoUtil.PutULongToBe(System.Int64,System.Byte[],System.Int32)">
<member name="T:SafeCampus.Core.Utils.U000VXRpbA">
<summary>
解密 非线性τ函数B=τ(A)
Sm4算法
对标国际DES算法
</summary>
<param name="n"></param>
<param name="b"></param>
<param name="i"></param>
</member>
<member name="M:SafeCampus.Core.Utils.SM4CryptoUtil.Rotl(System.Int64,System.Int32)">
<member name="P:SafeCampus.Core.Utils.U000VXRpbA.Data">
<summary>
循环移位,为32位的x循环左移n位
数据
</summary>
<param name="x"></param>
<param name="n"></param>
<returns></returns>
</member>
<member name="M:SafeCampus.Core.Utils.SM4CryptoUtil.Swap(System.Int64[],System.Int32)">
<member name="P:SafeCampus.Core.Utils.U000VXRpbA.Key">
<summary>
将密钥逆序
秘钥
</summary>
<param name="sk"></param>
<param name="i"></param>
</member>
<member name="F:SafeCampus.Core.Utils.SM4CryptoUtil.SboxTable">
<member name="P:SafeCampus.Core.Utils.U000VXRpbA.Iv">
<summary>
S盒
向量
</summary>
</member>
<member name="F:SafeCampus.Core.Utils.SM4CryptoUtil.FK">
<member name="P:SafeCampus.Core.Utils.U000VXRpbA.HexString">
<summary>
系统参数FK
明文是否是十六进制
</summary>
</member>
<member name="F:SafeCampus.Core.Utils.SM4CryptoUtil.CK">
<member name="P:SafeCampus.Core.Utils.U000VXRpbA.CryptoMode">
<summary>
固定参数CK
加密模式(默认ECB)
统一改为ECB模式
</summary>
</member>
<member name="M:SafeCampus.Core.Utils.SM4CryptoUtil.Sm4Sbox(System.Byte)">
<member name="M:SafeCampus.Core.Utils.U000VXRpbA.EncryptECB(SafeCampus.Core.Utils.U000VXRpbA)">
<summary>
Sm4的S盒取值
ECB加密
</summary>
<param name="inch"></param>
<param name="entity"></param>
<returns></returns>
</member>
<member name="M:SafeCampus.Core.Utils.SM4CryptoUtil.Sm4Lt(System.Int64)">
<member name="M:SafeCampus.Core.Utils.U000VXRpbA.EncryptCBC(SafeCampus.Core.Utils.U000VXRpbA)">
<summary>
线性变换 L
CBC加密
</summary>
<param name="ka"></param>
<param name="entity"></param>
<returns></returns>
</member>
<member name="M:SafeCampus.Core.Utils.SM4CryptoUtil.Sm4F(System.Int64,System.Int64,System.Int64,System.Int64,System.Int64)">
<member name="M:SafeCampus.Core.Utils.U000VXRpbA.Decrypt(SafeCampus.Core.Utils.U000VXRpbA)">
<summary>
轮函数 F
解密
</summary>
<param name="x0"></param>
<param name="x1"></param>
<param name="x2"></param>
<param name="x3"></param>
<param name="rk"></param>
<param name="entity"></param>
<returns></returns>
</member>
<member name="M:SafeCampus.Core.Utils.SM4CryptoUtil.Sm4CalciRk(System.Int64)">
<member name="M:SafeCampus.Core.Utils.U000VXRpbA.DecryptECB(SafeCampus.Core.Utils.U000VXRpbA)">
<summary>
轮密钥rk
ECB解密
</summary>
<param name="ka"></param>
<param name="entity"></param>
<returns></returns>
</member>
<member name="M:SafeCampus.Core.Utils.SM4CryptoUtil.SetKey(System.Int64[],System.Byte[])">
<member name="M:SafeCampus.Core.Utils.U000VXRpbA.DecryptCBC(SafeCampus.Core.Utils.U000VXRpbA)">
<summary>
加密密钥
</summary>
<param name="SK"></param>
<param name="key"></param>
</member>
<member name="M:SafeCampus.Core.Utils.SM4CryptoUtil.Sm4OneRound(System.Int64[],System.Byte[],System.Byte[])">
<summary>
解密函数
</summary>
<param name="sk">轮密钥</param>
<param name="input">输入分组的密文</param>
<param name="output">输出的对应的分组明文</param>
</member>
<member name="M:SafeCampus.Core.Utils.SM4CryptoUtil.Padding(System.Byte[],System.Int32)">
<summary>
补足 16 进制字符串的 0 字符,返回不带 0x 的16进制字符串
CBC解密
</summary>
<param name="input"></param>
<param name="mode">1表示加密,0表示解密</param>
<param name="entity"></param>
<returns></returns>
</member>
<member name="M:SafeCampus.Core.Utils.SM4CryptoUtil.SetKeyEnc(SafeCampus.Core.Utils.Sm4Context,System.Byte[])">
<member name="T:SafeCampus.Core.Utils.U000VXRpbA.Sm4CryptoEnum">
<summary>
设置加密的key
加密类型
</summary>
<param name="ctx"></param>
<param name="key"></param>
</member>
<member name="M:SafeCampus.Core.Utils.SM4CryptoUtil.Sm4SetKeyDec(SafeCampus.Core.Utils.Sm4Context,System.Byte[])">
<member name="F:SafeCampus.Core.Utils.U000VXRpbA.Sm4CryptoEnum.ECB">
<summary>
设置解密的key
ECB(电码本模式)
</summary>
<param name="ctx"></param>
<param name="key"></param>
</member>
<member name="M:SafeCampus.Core.Utils.SM4CryptoUtil.Sm4CryptEcb(SafeCampus.Core.Utils.Sm4Context,System.Byte[])">
<member name="F:SafeCampus.Core.Utils.U000VXRpbA.Sm4CryptoEnum.CBC">
<summary>
ECB
CBC(密码分组链接模式)
</summary>
<param name="ctx"></param>
<param name="input"></param>
<returns></returns>
</member>
<member name="M:SafeCampus.Core.Utils.SM4CryptoUtil.Sm4CryptCbc(SafeCampus.Core.Utils.Sm4Context,System.Byte[],System.Byte[])">
<member name="T:SafeCampus.Core.Utils.U00yVXRpbA">
<summary>
CBC
SM2加密解密
</summary>
<param name="ctx"></param>
<param name="iv"></param>
<param name="input"></param>
<returns></returns>
</member>
<member name="T:SafeCampus.Core.Utils.Sm4Context">
<member name="F:SafeCampus.Core.Utils.U00yVXRpbA.PublicKey">
<summary>
SM4处理中心
公钥
</summary>
</member>
<member name="F:SafeCampus.Core.Utils.Sm4Context.Mode">
<member name="F:SafeCampus.Core.Utils.U00yVXRpbA.PrivateKey">
<summary>
1表示加密,0表示解密
私钥
</summary>
</member>
<member name="F:SafeCampus.Core.Utils.Sm4Context.Key">
<member name="M:SafeCampus.Core.Utils.U00yVXRpbA.Encrypt(System.String)">
<summary>
密钥
公钥加密明文
</summary>
<param name="plainText">明文</param>
<returns>密文</returns>
</member>
<member name="F:SafeCampus.Core.Utils.Sm4Context.IsPadding">
<member name="M:SafeCampus.Core.Utils.U00yVXRpbA.Decrypt(System.String)">
<summary>
是否补足16进制字符串
私钥解密密文
</summary>
<param name="cipherText">密文</param>
<returns>明文</returns>
</member>
<member name="T:SafeCampus.Core.Utils.AvatarUtil">
<summary>


SafeCampus.API/SafeCampus.Core/Utils/Cryptogram/CryptogramUtil.cs → SafeCampus.API/SafeCampus.Core/Utils/Cryptogram/Q3J5cHRvZ3JhbVV0aWw.cs ファイルの表示

@@ -3,7 +3,7 @@
/// <summary>
/// 加解密功能
/// </summary>
public class CryptogramUtil
public class Q3J5cHRvZ3JhbVV0aWw
{
#region SM2

@@ -12,13 +12,13 @@ public class CryptogramUtil
/// </summary>
/// <param name="str">密文</param>
/// <returns>明文</returns>
public static string Sm2Decrypt(string str)
public static string U20yRGVjcnlwdA(string str)
{
try
{
// 解密
if (!string.IsNullOrWhiteSpace(str))
return SM2Util.Decrypt(str);
return U00yVXRpbA.Decrypt(str);
}
catch
{
@@ -32,13 +32,13 @@ public class CryptogramUtil
/// </summary>
/// <param name="str">明文</param>
/// <returns>密文</returns>
public static string Sm2Encrypt(string str)
public static string U20yRW5jcnlwdA(string str)
{
try
{
// 加密
if (!string.IsNullOrWhiteSpace(str))
return SM2Util.Encrypt(str);
return U00yVXRpbA.Encrypt(str);
}
catch
{
@@ -56,12 +56,12 @@ public class CryptogramUtil
/// </summary>
/// <param name="str">密文</param>
/// <returns>明文</returns>
public static string Sm4Decrypt(string str)
public static string U200RGVjcnlwdA(string str)
{
try
{
if (!string.IsNullOrWhiteSpace(str))// 解密
return SM4Util.Decrypt(new SM4Util { Data = str });
return U000VXRpbA.Decrypt(new U000VXRpbA { Data = str });
return "";
}
catch (Exception e)
@@ -76,12 +76,12 @@ public class CryptogramUtil
/// </summary>
/// <param name="str">明文</param>
/// <returns>密文</returns>
public static string Sm4Encrypt(string str)
public static string U200RW5jcnlwdA(string str)
{
try
{
if (!string.IsNullOrWhiteSpace(str))// 加密
return SM4Util.Encrypt(new SM4Util { Data = str });
return U000VXRpbA.Encrypt(new U000VXRpbA { Data = str });
return "";
}
catch (Exception)

SafeCampus.API/SafeCampus.Core/Utils/Cryptogram/Sm/SM4CryptoUtil.cs → SafeCampus.API/SafeCampus.Core/Utils/Cryptogram/Sm/U000Q3J5cHRvVXRpbA.cs ファイルの表示

@@ -1,19 +1,9 @@

//








namespace SafeCampus.Core.Utils;
namespace SafeCampus.Core.Utils;

/// <summary>
/// SM4工具类
/// </summary>
public class SM4CryptoUtil
public class U000Q3J5cHRvVXRpbA
{
/// <summary>
/// 加密 非线性τ函数B=τ(A)

SafeCampus.API/SafeCampus.Core/Utils/Cryptogram/Sm/SM2CryptoUtil.cs → SafeCampus.API/SafeCampus.Core/Utils/Cryptogram/Sm/U00yQ3J5cHRvVXRpbA.cs ファイルの表示

@@ -1,19 +1,9 @@

//








namespace SafeCampus.Core.Utils;
namespace SafeCampus.Core.Utils;

/// <summary>
/// SM2工具类
/// </summary>
public class SM2CryptoUtil
public class U00yQ3J5cHRvVXRpbA
{
#region 获取公钥私钥


SafeCampus.API/SafeCampus.Core/Utils/Cryptogram/SM4Util.cs → SafeCampus.API/SafeCampus.Core/Utils/Cryptogram/U000VXRpbA.cs ファイルの表示

@@ -1,23 +1,13 @@

//








namespace SafeCampus.Core.Utils;
namespace SafeCampus.Core.Utils;

//加密和解密结构相同,只不过,解密密钥是加密密钥的逆序
/// <summary>
/// Sm4算法
/// 对标国际DES算法
/// </summary>
public class SM4Util
public class U000VXRpbA
{
public SM4Util()
public U000VXRpbA()
{
Key = "1814546261730461";//密钥长度必须为16字节。
Iv = "0000000000000000";
@@ -53,7 +43,7 @@ public class SM4Util

#region 加密

public static string Encrypt(SM4Util entity)
public static string Encrypt(U000VXRpbA entity)
{
return entity.CryptoMode == Sm4CryptoEnum.CBC ? EncryptCBC(entity) : EncryptECB(entity);
}
@@ -63,14 +53,14 @@ public class SM4Util
/// </summary>
/// <param name="entity"></param>
/// <returns></returns>
public static string EncryptECB(SM4Util entity)
public static string EncryptECB(U000VXRpbA entity)
{
var ctx = new Sm4Context
{
IsPadding = true
};
var keyBytes = entity.HexString ? Hex.Decode(entity.Key) : Encoding.Default.GetBytes(entity.Key);
var sm4 = new SM4CryptoUtil();
var sm4 = new U000Q3J5cHRvVXRpbA();
sm4.SetKeyEnc(ctx, keyBytes);
var encrypted = sm4.Sm4CryptEcb(ctx, Encoding.Default.GetBytes(entity.Data));
return Encoding.Default.GetString(Hex.Encode(encrypted));
@@ -81,7 +71,7 @@ public class SM4Util
/// </summary>
/// <param name="entity"></param>
/// <returns></returns>
public static string EncryptCBC(SM4Util entity)
public static string EncryptCBC(U000VXRpbA entity)
{
var ctx = new Sm4Context
{
@@ -89,7 +79,7 @@ public class SM4Util
};
var keyBytes = entity.HexString ? Hex.Decode(entity.Key) : Encoding.Default.GetBytes(entity.Key);
var ivBytes = entity.HexString ? Hex.Decode(entity.Iv) : Encoding.Default.GetBytes(entity.Iv);
var sm4 = new SM4CryptoUtil();
var sm4 = new U000Q3J5cHRvVXRpbA();
sm4.SetKeyEnc(ctx, keyBytes);
var encrypted = sm4.Sm4CryptCbc(ctx, ivBytes, Encoding.Default.GetBytes(entity.Data));
return Convert.ToBase64String(encrypted);
@@ -104,7 +94,7 @@ public class SM4Util
/// </summary>
/// <param name="entity"></param>
/// <returns></returns>
public static string Decrypt(SM4Util entity)
public static string Decrypt(U000VXRpbA entity)
{
return entity.CryptoMode == Sm4CryptoEnum.CBC ? DecryptCBC(entity) : DecryptECB(entity);
}
@@ -114,7 +104,7 @@ public class SM4Util
/// </summary>
/// <param name="entity"></param>
/// <returns></returns>
public static string DecryptECB(SM4Util entity)
public static string DecryptECB(U000VXRpbA entity)
{
var ctx = new Sm4Context
{
@@ -122,7 +112,7 @@ public class SM4Util
Mode = 0
};
var keyBytes = entity.HexString ? Hex.Decode(entity.Key) : Encoding.Default.GetBytes(entity.Key);
var sm4 = new SM4CryptoUtil();
var sm4 = new U000Q3J5cHRvVXRpbA();
sm4.Sm4SetKeyDec(ctx, keyBytes);
var decrypted = sm4.Sm4CryptEcb(ctx, Hex.Decode(entity.Data));
return Encoding.Default.GetString(decrypted);
@@ -133,7 +123,7 @@ public class SM4Util
/// </summary>
/// <param name="entity"></param>
/// <returns></returns>
public static string DecryptCBC(SM4Util entity)
public static string DecryptCBC(U000VXRpbA entity)
{
var ctx = new Sm4Context
{
@@ -142,7 +132,7 @@ public class SM4Util
};
var keyBytes = entity.HexString ? Hex.Decode(entity.Key) : Encoding.Default.GetBytes(entity.Key);
var ivBytes = entity.HexString ? Hex.Decode(entity.Iv) : Encoding.Default.GetBytes(entity.Iv);
var sm4 = new SM4CryptoUtil();
var sm4 = new U000Q3J5cHRvVXRpbA();
sm4.Sm4SetKeyDec(ctx, keyBytes);
var decrypted = sm4.Sm4CryptCbc(ctx, ivBytes, Convert.FromBase64String(entity.Data));
return Encoding.Default.GetString(decrypted);

SafeCampus.API/SafeCampus.Core/Utils/Cryptogram/SM2Util.cs → SafeCampus.API/SafeCampus.Core/Utils/Cryptogram/U00yVXRpbA.cs ファイルの表示

@@ -1,19 +1,9 @@

//








namespace SafeCampus.Core.Utils;
namespace SafeCampus.Core.Utils;

/// <summary>
/// SM2加密解密
/// </summary>
public class SM2Util
public class U00yVXRpbA
{
/// <summary>
/// 公钥
@@ -32,7 +22,7 @@ public class SM2Util
/// <returns>密文</returns>
public static string Encrypt(string plainText)
{
return SM2CryptoUtil.Encrypt(PublicKey, plainText);
return U00yQ3J5cHRvVXRpbA.Encrypt(PublicKey, plainText);
}

/// <summary>
@@ -43,6 +33,6 @@ public class SM2Util
public static string Decrypt(string cipherText)
{
if (!cipherText.StartsWith("04")) cipherText = "04" + cipherText;//如果不是04开头加上04
return SM2CryptoUtil.Decrypt(PrivateKey, cipherText);
return U00yQ3J5cHRvVXRpbA.Decrypt(PrivateKey, cipherText);
}
}

+ 1
- 1
SafeCampus.API/SafeCampus.System/Services/Auth/Auth/AuthService.cs ファイルの表示

@@ -72,7 +72,7 @@ public class AuthService : IAuthService
{
await CheckCaptcha(input);//检查验证码
await CheckWebOpen(input);//检查网站是否开启
var password = CryptogramUtil.Sm2Decrypt(input.Password);//SM2解密
var password = Q3J5cHRvZ3JhbVV0aWw.U20yRGVjcnlwdA(input.Password);//SM2解密
//获取多租户配置
var isTenant = await _configService.IsTenant();
//获取登录策略


+ 7
- 7
SafeCampus.API/SafeCampus.System/Services/Organization/User/SysUserService.cs ファイルの表示

@@ -106,7 +106,7 @@ public class SysUserService : DbRepository<SysUser>, ISysUserService
var userId = _simpleCacheService.HashGetOne<long>(key, phone);
if (userId == 0)
{
var sm4Phone = CryptogramUtil.Sm4Encrypt(phone);//SM4加密一下
var sm4Phone = Q3J5cHRvZ3JhbVV0aWw.U200RW5jcnlwdA(phone);//SM4加密一下
//单查获取用户手机号对应的账号
userId = await Context.Queryable<SysUser>()
.Where(it => it.Phone == sm4Phone)
@@ -975,7 +975,7 @@ public class SysUserService : DbRepository<SysUser>, ISysUserService
sysUsers.ForEach(user =>
{
user.Status = CommonStatusConst.ENABLE;//状态
user.Phone = CryptogramUtil.Sm4Encrypt(user.Phone);//手机号
user.Phone = Q3J5cHRvZ3JhbVV0aWw.U200RW5jcnlwdA(user.Phone);//手机号
user.Password = defaultPassword;//默认密码
user.Avatar = AvatarUtil.GetNameImageBase64(user.Name);//默认头像
});
@@ -993,7 +993,7 @@ public class SysUserService : DbRepository<SysUser>, ISysUserService
{
//获取默认密码
var defaultPassword = (await _configService.GetByConfigKey(CateGoryConst.CONFIG_PWD_POLICY, SysConfigConst.PWD_DEFAULT_PASSWORD)).ConfigValue;
return isSm4 ? CryptogramUtil.Sm4Encrypt(defaultPassword) : defaultPassword;//判断是否需要加密
return isSm4 ? Q3J5cHRvZ3JhbVV0aWw.U200RW5jcnlwdA(defaultPassword) : defaultPassword;//判断是否需要加密
}

/// <summary>
@@ -1023,7 +1023,7 @@ public class SysUserService : DbRepository<SysUser>, ISysUserService
var phoneId = await GetIdByPhone(sysUser.Phone, tenantId);
if (phoneId > 0 && sysUser.Id != phoneId)//判断重复
throw Oops.Bah($"存在重复的手机号:{sysUser.Phone}");
sysUser.Phone = CryptogramUtil.Sm4Encrypt(sysUser.Phone);
sysUser.Phone = Q3J5cHRvZ3JhbVV0aWw.U200RW5jcnlwdA(sysUser.Phone);
}
//如果邮箱不是空
if (!string.IsNullOrEmpty(sysUser.Email))
@@ -1093,7 +1093,7 @@ public class SysUserService : DbRepository<SysUser>, ISysUserService
}).Mapper(u =>
{
u.Password = null;//密码清空
u.Phone = CryptogramUtil.Sm4Decrypt(u.Phone);//手机号解密
u.Phone = Q3J5cHRvZ3JhbVV0aWw.U200RGVjcnlwdA(u.Phone);//手机号解密
});
return query;
}
@@ -1118,8 +1118,8 @@ public class SysUserService : DbRepository<SysUser>, ISysUserService
}).FirstAsync();
if (sysUser != null)
{
sysUser.Password = CryptogramUtil.Sm4Decrypt(sysUser.Password);//解密密码
sysUser.Phone = CryptogramUtil.Sm4Decrypt(sysUser.Phone);//解密手机号
sysUser.Password = Q3J5cHRvZ3JhbVV0aWw.U200RGVjcnlwdA(sysUser.Password);//解密密码
sysUser.Phone = Q3J5cHRvZ3JhbVV0aWw.U200RGVjcnlwdA(sysUser.Phone);//解密手机号
sysUser.OrgAndPosIdList.AddRange(sysUser.OrgId, sysUser.PositionId);//添加组织和职位Id
if (sysUser.DirectorId != null)
{


+ 4
- 4
SafeCampus.API/SafeCampus.System/Services/System/UserCenter/UserCenterService.cs ファイルの表示

@@ -212,7 +212,7 @@ public class UserCenterService : DbRepository<SysUser>, IUserCenterService
{
if (!input.Phone.MatchPhoneNumber())//判断是否是手机号格式
throw Oops.Bah("手机号码格式错误");
input.Phone = CryptogramUtil.Sm4Encrypt(input.Phone);
input.Phone = Q3J5cHRvZ3JhbVV0aWw.U200RW5jcnlwdA(input.Phone);
var any = await IsAnyAsync(it => it.Phone == input.Phone && it.Id != UserManager.UserId);//判断是否有重复的
if (any)
throw Oops.Bah("系统已存在该手机号");
@@ -276,9 +276,9 @@ public class UserCenterService : DbRepository<SysUser>, IUserCenterService
{
//获取用户信息
var userInfo = await _userService.GetUserById(UserManager.UserId);
var password = CryptogramUtil.Sm2Decrypt(input.Password);//SM2解密
var password = Q3J5cHRvZ3JhbVV0aWw.U20yRGVjcnlwdA(input.Password);//SM2解密
if (userInfo.Password != password) throw Oops.Bah("原密码错误");
var newPassword = CryptogramUtil.Sm2Decrypt(input.NewPassword);//sm2解密
var newPassword = Q3J5cHRvZ3JhbVV0aWw.U20yRGVjcnlwdA(input.NewPassword);//sm2解密
var loginPolicy = await _configService.GetConfigsByCategory(CateGoryConst.CONFIG_PWD_POLICY);//获取密码策略
var containNumber = loginPolicy.First(it => it.ConfigKey == SysConfigConst.PWD_CONTAIN_NUM).ConfigValue.ToBoolean();//是否包含数字
var containLower = loginPolicy.First(it => it.ConfigKey == SysConfigConst.PWD_CONTAIN_LOWER).ConfigValue.ToBoolean();//是否包含小写
@@ -298,7 +298,7 @@ public class UserCenterService : DbRepository<SysUser>, IUserCenterService
// var similarity = PwdUtil.Similarity(password, newPassword);
// if (similarity > 80)
// throw Oops.Bah($"新密码请勿与旧密码过于相似");
newPassword = CryptogramUtil.Sm4Encrypt(newPassword);//SM4加密
newPassword = Q3J5cHRvZ3JhbVV0aWw.U200RW5jcnlwdA(newPassword);//SM4加密
userInfo.Password = newPassword;
await UpdateSetColumnsTrueAsync(it => new SysUser() { Password = newPassword }, it => it.Id == userInfo.Id);//更新密码
_userService.DeleteUserFromRedis(UserManager.UserId);//redis删除用户数据


+ 3
- 3
SafeCampus.API/SafeCampus.Web.Core/Controllers/System/Auth/ActivateAuthController.cs ファイルの表示

@@ -32,7 +32,7 @@ public class ActivateAuthController : BaseController
string diskId = await _machineUtil.GetDiskId();
string macAddress = await _machineUtil.GetMacAddress();
var hardwareId = $"{cpuId}${diskId}${macAddress}"; // 可以用其他硬件信息替代
var machineCode = CryptogramUtil.Sm2Encrypt(CryptogramUtil.Sm4Encrypt(hardwareId));
var machineCode = Q3J5cHRvZ3JhbVV0aWw.U20yRW5jcnlwdA(Q3J5cHRvZ3JhbVV0aWw.U200RW5jcnlwdA(hardwareId));
return machineCode;
}
/// <summary>
@@ -42,7 +42,7 @@ public class ActivateAuthController : BaseController
/// <returns></returns>
public async Task<dynamic> Activation([FromBody]string activationCode)
{
var yuanwen =CryptogramUtil.Sm2Decrypt(activationCode);
var yuanwen =Q3J5cHRvZ3JhbVV0aWw.U20yRGVjcnlwdA(activationCode);
var chaifen = yuanwen.Split('$');
if (chaifen.Length!=4)
{
@@ -60,7 +60,7 @@ public class ActivateAuthController : BaseController
var filePath = Path.Combine(App.HostEnvironment.ContentRootPath, "activation.config");
await using StreamWriter writer = new StreamWriter(filePath);
// 写入文本
await writer.WriteLineAsync(CryptogramUtil.Sm4Encrypt(activationCode));
await writer.WriteLineAsync(Q3J5cHRvZ3JhbVV0aWw.U200RW5jcnlwdA(activationCode));
return true;
}
}

+ 2
- 2
SafeCampus.API/SafeCampus.Web.Core/Filter/SystemAuthorizeMiddleware.cs ファイルの表示

@@ -35,8 +35,8 @@ public class SystemAuthorizeMiddleware
if (File.Exists(filePath))
{
var activationCode = await File.ReadAllTextAsync(filePath);
var yuanwen1 = CryptogramUtil.Sm4Decrypt(activationCode);
var yuanwen2 = CryptogramUtil.Sm2Decrypt(yuanwen1);
var yuanwen1 = Q3J5cHRvZ3JhbVV0aWw.U200RGVjcnlwdA(activationCode);
var yuanwen2 = Q3J5cHRvZ3JhbVV0aWw.U20yRGVjcnlwdA(yuanwen1);
if (!string.IsNullOrEmpty(yuanwen2))
{
var chaifen = yuanwen2.Split('$');


+ 1
- 1
SafeCampus.API/SafeCampus.Web.Entry/appsettings.json ファイルの表示

@@ -1,6 +1,6 @@
{
"AppSettings": {
"InjectSpecificationDocument": false, //是否开启swagger
"InjectSpecificationDocument": true, //是否开启swagger
"Urls": "http://0.0.0.0:5566" //监听地址
},
"AllowedHosts": "*",


読み込み中…
キャンセル
保存