|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
-
- //
-
-
-
-
-
-
-
-
- namespace SafeCampus.Core.Utils;
-
- /// <summary>
- /// 加解密功能
- /// </summary>
- public class CryptogramUtil
- {
- #region SM2
-
- /// <summary>
- /// SM2解密
- /// </summary>
- /// <param name="str">密文</param>
- /// <returns>明文</returns>
- public static string Sm2Decrypt(string str)
- {
- // 解密
- if (!string.IsNullOrWhiteSpace(str))
- return SM2Util.Decrypt(str);
- try
- {
- // // 解密
- // if (!string.IsNullOrWhiteSpace(str))
- // return SM2Util.Decrypt(str);
- }
- catch
- {
- return "";
- }
- return "";
- }
-
- /// <summary>
- /// SM2加密
- /// </summary>
- /// <param name="str">明文</param>
- /// <returns>密文</returns>
- public static string Sm2Encrypt(string str)
- {
- try
- {
- // 加密
- if (!string.IsNullOrWhiteSpace(str))
- return SM2Util.Encrypt(str);
- }
- catch
- {
- return "";
- }
- return "";
- }
-
- #endregion SM2
-
- #region Sm4
-
- /// <summary>
- /// SM4解密
- /// </summary>
- /// <param name="str">密文</param>
- /// <returns>明文</returns>
- public static string Sm4Decrypt(string str)
- {
- if (!string.IsNullOrWhiteSpace(str))// 解密
- return SM4Util.Decrypt(new SM4Util { Data = str });
- return "";
- }
-
- /// <summary>
- /// SM4加密
- /// </summary>
- /// <param name="str">明文</param>
- /// <returns>密文</returns>
- public static string Sm4Encrypt(string str)
- {
- if (!string.IsNullOrWhiteSpace(str))// 加密
- return SM4Util.Encrypt(new SM4Util { Data = str });
- return "";
- }
-
- #endregion Sm4
- }
|