資源簡介
中國銀行-網上支付接口.net語言開發示例.rar

代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.Linq;
using?System.Text;
using?System.Security;
using?System.Security.Cryptography;
using?System.Security.Cryptography.Pkcs;
using?System.Security.Cryptography.X509Certificates;
using?System.IO;
namespace?P7Verify_CSharp
{
????class?PKCS7Tool
????{
????????public?static?byte[]?DecodeFromFile(string?inFileName)
????????{
????????????Frombase64Transform?myTransform?=?new?Frombase64Transform(Frombase64TransformMode.IgnoreWhiteSpaces);
????????????byte[]?myOutputBytes?=?new?byte[myTransform.OutputBlockSize];
????????????//Open?the?input?and?output?files.
????????????FileStream?myInputFile?=?new?FileStream(inFileName?FileMode.Open?FileAccess.Read);
????????????//Retrieve?the?file?contents?into?a?byte?array.
????????????byte[]?myInputBytes?=?new?byte[myInputFile.Length];
????????????myInputFile.Read(myInputBytes?0?myInputBytes.Length);
????????????MemoryStream?outputDataStream?=?new?MemoryStream(myInputBytes.Length);
????????????//Transform?the?data?in?chunks?the?size?of?InputBlockSize.
????????????int?i?=?0;
????????????int?inputBlockSize?=?4;
????????????while?(myInputBytes.Length?-?i?>?inputBlockSize)
????????????{
????????????????int?nOutput?=?myTransform.TransformBlock(myInputBytes?i?inputBlockSize?myOutputBytes?0);
????????????????i?+=?inputBlockSize;
????????????????if?(nOutput?>?0)
????????????????{
????????????????????outputDataStream.Write(myOutputBytes?0?nOutput);
????????????????}
????????????}
????????????//Transform?the?final?block?of?data.
????????????myOutputBytes?=?myTransform.TransformFinalBlock(myInputBytes?i?myInputBytes.Length?-?i);
????????????outputDataStream.Write(myOutputBytes?0?myOutputBytes.Length);
????????????//Free?up?any?used?resources.
????????????myTransform.Clear();
????????????myInputFile.Close();
????????????outputDataStream.Position?=?0;
????????????byte[]?outputData?=?new?byte[outputDataStream.Length];
????????????outputDataStream.Read(outputData?0?(int)outputDataStream.Length);
????????????outputDataStream.Close();
????????????return?outputData;
????????}
????????public?static?Boolean?Verify(byte[]?sig?byte[]?msgstring?dn)
????????{
????????????Boolean?b?=?true;
????????????try
????????????{
????????????????ContentInfo?signedData?=?new?ContentInfo(msg);
????????????????SignedCms?cms?=?new?SignedCms(signedData?true);
????????????????cms.Decode(sig);
????????????????//Check?Signature
????????????????cms.CheckSignature(true);
????????????????//Check?dn
????????????????if?(cms.Certificates.Count?>?0?)
????????????????{
????????????????????X509Certificate2?cert?=?cms.Certificates[0];
????????????????????if?(!string.IsNullOrEmpty(dn)?&&?!dn.Equals(cert.Subject))
????????????????????{
????????????????????????b?=?false;
????????????????????}
????????????????}
????????????????byte[]?data?=?cms.Encode();
????????????}
????????????catch?(Exception?e)
????
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
????.......???????117??2012-05-15?11:08??網上支付接口.net語言開發示例\P7Verify_CSharp\P7Verify_CSharp\app.config
????.......??????2677??2012-05-15?11:08??網上支付接口.net語言開發示例\P7Verify_CSharp\P7Verify_CSharp\P7Verify_CSharp.csproj
????.......???????330??2012-05-15?11:08??網上支付接口.net語言開發示例\P7Verify_CSharp\P7Verify_CSharp\P7Verify_CSharp.csproj.user
????.......???????257??2012-05-15?11:08??網上支付接口.net語言開發示例\P7Verify_CSharp\P7Verify_CSharp\P7Verify_CSharp.csproj.vspscc
????.......??????5763??2012-05-15?11:08??網上支付接口.net語言開發示例\P7Verify_CSharp\P7Verify_CSharp\PKCS7Tool.cs
????.......??????3968??2012-05-15?11:08??網上支付接口.net語言開發示例\P7Verify_CSharp\P7Verify_CSharp\Program.cs
????.......??????1442??2012-05-15?11:08??網上支付接口.net語言開發示例\P7Verify_CSharp\P7Verify_CSharp\Properties\AssemblyInfo.cs
????.......??????1393??2012-05-15?11:08??網上支付接口.net語言開發示例\P7Verify_CSharp\P7Verify_CSharp.sln
????.......???????222??2012-05-15?11:08??網上支付接口.net語言開發示例\readme.txt
????.......??????1046??2012-05-15?11:08??網上支付接口.net語言開發示例\證書以及測試文件\BOC-CA.cer
????.......??????1900??2012-05-15?11:08??網上支付接口.net語言開發示例\證書以及測試文件\demo.pfx
????.......??????1308??2012-05-15?11:08??網上支付接口.net語言開發示例\證書以及測試文件\sign.txt
????.......??????1276??2012-05-15?11:08??網上支付接口.net語言開發示例\證書以及測試文件\signDotNet.txt
????.......????????34??2012-05-15?11:08??網上支付接口.net語言開發示例\證書以及測試文件\text.txt
?????目錄??????????0??2013-04-23?11:09??網上支付接口.net語言開發示例\P7Verify_CSharp\P7Verify_CSharp\Properties
?????目錄??????????0??2013-04-23?11:09??網上支付接口.net語言開發示例\P7Verify_CSharp\P7Verify_CSharp
?????目錄??????????0??2013-04-23?11:09??網上支付接口.net語言開發示例\P7Verify_CSharp
?????目錄??????????0??2013-04-23?11:09??網上支付接口.net語言開發示例\證書以及測試文件
?????目錄??????????0??2013-04-23?11:09??網上支付接口.net語言開發示例
????.......???1048064??2012-05-15?11:08??中行公鑰證書(電子支付二級根證書)下載指引.ppt
?????文件?????565760??2011-12-17?17:04??B2C商戶端接口說明(ver?2.3).doc
-----------?---------??----------?-----??----
??????????????1635557????????????????????21
- 上一篇:840D sl機床數據和參數
- 下一篇:一個完整的前臺和后臺都有的電子商務網站
評論
共有 條評論