/// <summary>5.4.3 PKCS#7解密 /// /// </summary> /// <param name="sSignData"></param> /// <returns></returns> public static byte[] decryptPKCS7(String sSignData) { try { Utilities oUtilities = new Utilities(); byte[] bSignData = (byte[])oUtilities.Base64Decode(sSignData); SecuInter.EnvelopedData oEnv = new SecuInter.EnvelopedData(); oEnv.Decrypt(bSignData); byte[] rt = (byte[])oEnv.Content; //IEnumerator oenum=oEnv.Recipients.GetEnumerator(); //((SecuInter.X509Certificate)oenum.Current).Display(); oEnv = null; return(rt); } catch (Exception) { return(null); } }
/// <summary>5.4.2 PKCS#7加密 /// /// </summary> /// <param name="bSource"></param> /// <returns></returns> public static String encryptPKCS7(byte[] bSource, SecuInter.X509Certificate oCert) { if (oCert == null) { throw new Exception("未选择证书,请检查是否插入密钥!"); } if (bSource.Length == 0) { throw new Exception("原文为空!"); } SecuInter.EnvelopedData oEnv = new SecuInter.EnvelopedData(); oEnv.Algorithm = SECUINTER_ENCRYPT_ALGORITHM.SECUINTER_ALGORITHM_DES; oEnv.Recipients.Add(oCert); oEnv.Content = bSource; object arrRT = oEnv.Encrypt(SECUINTER_CMS_ENCODE_TYPE.SECUINTER_CMS_ENCODE_BASE64); oEnv = null; return(arrRT.ToString()); }