"景先生毕设|www.jxszl.com

C# DATA_BLOB类代码示例

2023-12-29 17:50编辑: www.jxszl.com景先生毕设
本文整理汇总了C#中DATA_BLOB类的典型用法代码示例。如果您正苦于以下问题:C#DATA_BLOB类的具体用法?C#DATA_BLOB怎么用?C#DATA_BLOB使用的例子?这里精选的类代码示例或许可以为您提供帮助。 示例1:Encrypt publicsealedoverridebyte[]Encrypt(CmsRecipientCollectionrecipients,ContentInfocontentInfo,AlgorithmIdentifiercontentEncryptionAlgorithm,X509Certificate2CollectionoriginatorCerts,CryptographicAttributeObjectCollectionunprotectedAttributes) { using(SafeCryptMsgHandlehCryptMsg=EncodeHelpers.CreateCryptMsgHandleToEncode(recipients,contentInfo.ContentType,contentEncryptionAlgorithm,originatorCerts,unprotectedAttributes)) { byte[]encodedContent; if(contentInfo.ContentType.Value.Equals(Oids.Pkcs7Data,StringComparison.OrdinalIgnoreCase)) { unsafe { byte[]content=contentInfo.Content; fixed(byte*pContent=content) { DATA_BLOBblob=newDATA_BLOB((IntPtr)pContent,(uint)(content.Length)); encodedContent=Interop.Crypt32.CryptEncodeObjectToByteArray(CryptDecodeObjectStructType.X509_OCTET_STRING,&blob); } } } else { encodedContent=contentInfo.Content; } if(encodedContent.Length>0) { if(!Interop.Crypt32.CryptMsgUpdate(hCryptMsg,encodedContent,encodedContent.Length,fFinal:true)) throwMarshal.GetLastWin32Error().ToCryptographicException(); } byte[]encodedMessage=hCryptMsg.GetMsgParamAsByteArray(CryptMsgParamType.CMSG_CONTENT_PARAM); returnencodedMessage; } }
原文链接:http://www.jxszl.com/biancheng/C/556891.html