Esempio n. 1
0
 public static string SM4DecryptData(string key, string data)
 {
     byte[] cipher = Convert.FromBase64String(data);
     byte[] plain  = SM4Util.DecryptCBC(cipher, Hex.Decode(key), Hex.Decode(key));
     return(Hex.ToHexString(cipher, 0, cipher.Length));
 }
Esempio n. 2
0
 /// <summary>
 /// 使用国密SM4对文本加密字符串
 /// </summary>
 /// <param name="key"></param>
 /// <param name="data"></param>
 /// <returns></returns>
 public static string SM4EncryptData(string key, byte[] dataBytes)
 {
     //byte[] dataBytes = Encoding.UTF8.GetBytes(data);
     byte[] cipher = SM4Util.EncryptCBC(dataBytes, Hex.Decode(key), Hex.Decode(key));
     return(Convert.ToBase64String(cipher));
 }