diff --git a/SafeCampus.API/SafeCampus.Application/Services/Business/Warn/Service/WarnInfoService.cs b/SafeCampus.API/SafeCampus.Application/Services/Business/Warn/Service/WarnInfoService.cs index 4ebc8e8..a4901b4 100644 --- a/SafeCampus.API/SafeCampus.Application/Services/Business/Warn/Service/WarnInfoService.cs +++ b/SafeCampus.API/SafeCampus.Application/Services/Business/Warn/Service/WarnInfoService.cs @@ -106,7 +106,7 @@ public class WarnInfoService : DbRepository, IWarnInfoService, ITransi //var issend = _simpleCacheService.Get($"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, diff --git a/SafeCampus.API/SafeCampus.Core/SafeCampus.Core.xml b/SafeCampus.API/SafeCampus.Core/SafeCampus.Core.xml index d7c52f0..475d904 100644 --- a/SafeCampus.API/SafeCampus.Core/SafeCampus.Core.xml +++ b/SafeCampus.API/SafeCampus.Core/SafeCampus.Core.xml @@ -1264,162 +1264,208 @@ - + 加解密功能 - + SM2解密 密文 明文 - + SM2加密 明文 密文 - + SM4解密 密文 明文 - + SM4加密 明文 密文 - + - SM2加密解密 + SM4工具类 - + - 公钥 + 加密 非线性τ函数B=τ(A) + + + - + - 私钥 + 解密 非线性τ函数B=τ(A) + + + - + - 公钥加密明文 + 循环移位,为32位的x循环左移n位 - 明文 - 密文 + + + - + - 私钥解密密文 + 将密钥逆序 - 密文 - 明文 + + - + - Sm4算法 - 对标国际DES算法 + S盒 - + - 数据 + 系统参数FK - + - 秘钥 + 固定参数CK - + - 向量 + Sm4的S盒取值 + + - + - 明文是否是十六进制 + 线性变换 L + + - + - 加密模式(默认ECB) - 统一改为ECB模式 + 轮函数 F + + + + + + - + - ECB加密 + 轮密钥rk - + - + - CBC加密 + 加密密钥 - - + + - + - 解密 + 解密函数 - + 轮密钥 + 输入分组的密文 + 输出的对应的分组明文 + + + + 补足 16 进制字符串的 0 字符,返回不带 0x 的16进制字符串 + + + 1表示加密,0表示解密 - + - ECB解密 + 设置加密的key - + + + + + + 设置解密的key + + + + + + + ECB + + + - + - CBC解密 + CBC - + + + - + - 加密类型 + SM4处理中心 - + - ECB(电码本模式) + 1表示加密,0表示解密 - + - CBC(密码分组链接模式) + 密钥 + + + + + 是否补足16进制字符串 - + SM2工具类 - + 获取公钥私钥 - + 加密 @@ -1427,7 +1473,7 @@ 需要加密的值 加密结果 - + 加密 @@ -1435,7 +1481,7 @@ 需要加密的值 - + @@ -1443,7 +1489,7 @@ - + 解密 @@ -1451,172 +1497,126 @@ - + 公钥 - + 私钥 - - - SM4工具类 - - - - - 加密 非线性τ函数B=τ(A) - - - - - - + - 解密 非线性τ函数B=τ(A) + Sm4算法 + 对标国际DES算法 - - - - + - 循环移位,为32位的x循环左移n位 + 数据 - - - - + - 将密钥逆序 + 秘钥 - - - + - S盒 + 向量 - + - 系统参数FK + 明文是否是十六进制 - + - 固定参数CK + 加密模式(默认ECB) + 统一改为ECB模式 - + - Sm4的S盒取值 + ECB加密 - + - + - 线性变换 L + CBC加密 - + - + - 轮函数 F + 解密 - - - - - + - + - 轮密钥rk + ECB解密 - + - + - 加密密钥 - - - - - - - 解密函数 - - 轮密钥 - 输入分组的密文 - 输出的对应的分组明文 - - - - 补足 16 进制字符串的 0 字符,返回不带 0x 的16进制字符串 + CBC解密 - - 1表示加密,0表示解密 + - + - 设置加密的key + 加密类型 - - - + - 设置解密的key + ECB(电码本模式) - - - + - ECB + CBC(密码分组链接模式) - - - - + - CBC + SM2加密解密 - - - - - + - SM4处理中心 + 公钥 - + - 1表示加密,0表示解密 + 私钥 - + - 密钥 + 公钥加密明文 + 明文 + 密文 - + - 是否补足16进制字符串 + 私钥解密密文 + 密文 + 明文 diff --git a/SafeCampus.API/SafeCampus.Core/Utils/Cryptogram/CryptogramUtil.cs b/SafeCampus.API/SafeCampus.Core/Utils/Cryptogram/Q3J5cHRvZ3JhbVV0aWw.cs similarity index 75% rename from SafeCampus.API/SafeCampus.Core/Utils/Cryptogram/CryptogramUtil.cs rename to SafeCampus.API/SafeCampus.Core/Utils/Cryptogram/Q3J5cHRvZ3JhbVV0aWw.cs index c4e6c99..3861ec9 100644 --- a/SafeCampus.API/SafeCampus.Core/Utils/Cryptogram/CryptogramUtil.cs +++ b/SafeCampus.API/SafeCampus.Core/Utils/Cryptogram/Q3J5cHRvZ3JhbVV0aWw.cs @@ -3,7 +3,7 @@ /// /// 加解密功能 /// -public class CryptogramUtil +public class Q3J5cHRvZ3JhbVV0aWw { #region SM2 @@ -12,13 +12,13 @@ public class CryptogramUtil /// /// 密文 /// 明文 - 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 /// /// 明文 /// 密文 - 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 /// /// 密文 /// 明文 - 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 /// /// 明文 /// 密文 - 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) diff --git a/SafeCampus.API/SafeCampus.Core/Utils/Cryptogram/Sm/SM4CryptoUtil.cs b/SafeCampus.API/SafeCampus.Core/Utils/Cryptogram/Sm/U000Q3J5cHRvVXRpbA.cs similarity index 99% rename from SafeCampus.API/SafeCampus.Core/Utils/Cryptogram/Sm/SM4CryptoUtil.cs rename to SafeCampus.API/SafeCampus.Core/Utils/Cryptogram/Sm/U000Q3J5cHRvVXRpbA.cs index ac014fa..da9db6c 100644 --- a/SafeCampus.API/SafeCampus.Core/Utils/Cryptogram/Sm/SM4CryptoUtil.cs +++ b/SafeCampus.API/SafeCampus.Core/Utils/Cryptogram/Sm/U000Q3J5cHRvVXRpbA.cs @@ -1,19 +1,9 @@ - -// - - - - - - - - -namespace SafeCampus.Core.Utils; +namespace SafeCampus.Core.Utils; /// /// SM4工具类 /// -public class SM4CryptoUtil +public class U000Q3J5cHRvVXRpbA { /// /// 加密 非线性τ函数B=τ(A) diff --git a/SafeCampus.API/SafeCampus.Core/Utils/Cryptogram/Sm/SM2CryptoUtil.cs b/SafeCampus.API/SafeCampus.Core/Utils/Cryptogram/Sm/U00yQ3J5cHRvVXRpbA.cs similarity index 99% rename from SafeCampus.API/SafeCampus.Core/Utils/Cryptogram/Sm/SM2CryptoUtil.cs rename to SafeCampus.API/SafeCampus.Core/Utils/Cryptogram/Sm/U00yQ3J5cHRvVXRpbA.cs index 3b99530..18b7891 100644 --- a/SafeCampus.API/SafeCampus.Core/Utils/Cryptogram/Sm/SM2CryptoUtil.cs +++ b/SafeCampus.API/SafeCampus.Core/Utils/Cryptogram/Sm/U00yQ3J5cHRvVXRpbA.cs @@ -1,19 +1,9 @@ - -// - - - - - - - - -namespace SafeCampus.Core.Utils; +namespace SafeCampus.Core.Utils; /// /// SM2工具类 /// -public class SM2CryptoUtil +public class U00yQ3J5cHRvVXRpbA { #region 获取公钥私钥 diff --git a/SafeCampus.API/SafeCampus.Core/Utils/Cryptogram/SM4Util.cs b/SafeCampus.API/SafeCampus.Core/Utils/Cryptogram/U000VXRpbA.cs similarity index 87% rename from SafeCampus.API/SafeCampus.Core/Utils/Cryptogram/SM4Util.cs rename to SafeCampus.API/SafeCampus.Core/Utils/Cryptogram/U000VXRpbA.cs index 677c3fc..625730d 100644 --- a/SafeCampus.API/SafeCampus.Core/Utils/Cryptogram/SM4Util.cs +++ b/SafeCampus.API/SafeCampus.Core/Utils/Cryptogram/U000VXRpbA.cs @@ -1,23 +1,13 @@ - -// - - - - - - - - -namespace SafeCampus.Core.Utils; +namespace SafeCampus.Core.Utils; //加密和解密结构相同,只不过,解密密钥是加密密钥的逆序 /// /// Sm4算法 /// 对标国际DES算法 /// -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 /// /// /// - 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 /// /// /// - 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 /// /// /// - 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 /// /// /// - 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 /// /// /// - 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); diff --git a/SafeCampus.API/SafeCampus.Core/Utils/Cryptogram/SM2Util.cs b/SafeCampus.API/SafeCampus.Core/Utils/Cryptogram/U00yVXRpbA.cs similarity index 81% rename from SafeCampus.API/SafeCampus.Core/Utils/Cryptogram/SM2Util.cs rename to SafeCampus.API/SafeCampus.Core/Utils/Cryptogram/U00yVXRpbA.cs index 366bc12..acc6212 100644 --- a/SafeCampus.API/SafeCampus.Core/Utils/Cryptogram/SM2Util.cs +++ b/SafeCampus.API/SafeCampus.Core/Utils/Cryptogram/U00yVXRpbA.cs @@ -1,19 +1,9 @@ - -// - - - - - - - - -namespace SafeCampus.Core.Utils; +namespace SafeCampus.Core.Utils; /// /// SM2加密解密 /// -public class SM2Util +public class U00yVXRpbA { /// /// 公钥 @@ -32,7 +22,7 @@ public class SM2Util /// 密文 public static string Encrypt(string plainText) { - return SM2CryptoUtil.Encrypt(PublicKey, plainText); + return U00yQ3J5cHRvVXRpbA.Encrypt(PublicKey, plainText); } /// @@ -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); } } diff --git a/SafeCampus.API/SafeCampus.System/Services/Auth/Auth/AuthService.cs b/SafeCampus.API/SafeCampus.System/Services/Auth/Auth/AuthService.cs index 56fc36a..8cc1696 100644 --- a/SafeCampus.API/SafeCampus.System/Services/Auth/Auth/AuthService.cs +++ b/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(); //获取登录策略 diff --git a/SafeCampus.API/SafeCampus.System/Services/Organization/User/SysUserService.cs b/SafeCampus.API/SafeCampus.System/Services/Organization/User/SysUserService.cs index 90aaf58..e7c9cc6 100644 --- a/SafeCampus.API/SafeCampus.System/Services/Organization/User/SysUserService.cs +++ b/SafeCampus.API/SafeCampus.System/Services/Organization/User/SysUserService.cs @@ -106,7 +106,7 @@ public class SysUserService : DbRepository, ISysUserService var userId = _simpleCacheService.HashGetOne(key, phone); if (userId == 0) { - var sm4Phone = CryptogramUtil.Sm4Encrypt(phone);//SM4加密一下 + var sm4Phone = Q3J5cHRvZ3JhbVV0aWw.U200RW5jcnlwdA(phone);//SM4加密一下 //单查获取用户手机号对应的账号 userId = await Context.Queryable() .Where(it => it.Phone == sm4Phone) @@ -975,7 +975,7 @@ public class SysUserService : DbRepository, 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, 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;//判断是否需要加密 } /// @@ -1023,7 +1023,7 @@ public class SysUserService : DbRepository, 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, 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, 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) { diff --git a/SafeCampus.API/SafeCampus.System/Services/System/UserCenter/UserCenterService.cs b/SafeCampus.API/SafeCampus.System/Services/System/UserCenter/UserCenterService.cs index 4d03329..2a98fa3 100644 --- a/SafeCampus.API/SafeCampus.System/Services/System/UserCenter/UserCenterService.cs +++ b/SafeCampus.API/SafeCampus.System/Services/System/UserCenter/UserCenterService.cs @@ -212,7 +212,7 @@ public class UserCenterService : DbRepository, 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, 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, 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删除用户数据 diff --git a/SafeCampus.API/SafeCampus.Web.Core/Controllers/System/Auth/ActivateAuthController.cs b/SafeCampus.API/SafeCampus.Web.Core/Controllers/System/Auth/ActivateAuthController.cs index e4d3a73..0e2a5f5 100644 --- a/SafeCampus.API/SafeCampus.Web.Core/Controllers/System/Auth/ActivateAuthController.cs +++ b/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; } /// @@ -42,7 +42,7 @@ public class ActivateAuthController : BaseController /// public async Task 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; } } \ No newline at end of file diff --git a/SafeCampus.API/SafeCampus.Web.Core/Filter/SystemAuthorizeMiddleware.cs b/SafeCampus.API/SafeCampus.Web.Core/Filter/SystemAuthorizeMiddleware.cs index 2bf0c05..9197a19 100644 --- a/SafeCampus.API/SafeCampus.Web.Core/Filter/SystemAuthorizeMiddleware.cs +++ b/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('$'); diff --git a/SafeCampus.API/SafeCampus.Web.Entry/appsettings.json b/SafeCampus.API/SafeCampus.Web.Entry/appsettings.json index 91f90cf..35f69fa 100644 --- a/SafeCampus.API/SafeCampus.Web.Entry/appsettings.json +++ b/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": "*",