如何使用RSA算法签署文件并使用C#验证ASP.NET中的签名? [英] How to sign a file using RSA algorithm and verify the signature in ASP.NET with C#?
问题描述
我想使用RSA算法签名文件并验证签名
以下是场景:
1.外向文件将放在一个文件夹中
3.我们需要使用数字签名(使用RSA 256)对文件进行签名并发送到中央银行。
4.我们需要下载响应并验证签名,然后将文件复制到文件夹。
5.如果签名验证失败,则需要将响应发送到中央银行
要签署的文件:
I want to sign a file using RSA algorithm and verify the signature
Below are the scenarios:
1. Outward files will be put in a folder
3. We need to sign the file with a digital signature (using RSA 256) and send to Central Bank.
4. We need to download the response and verify the signature and then copy the file to a folder.
5. If the signature validation fails, a response needs to be send to Central Bank
The file to sign:
<?xml version="1.0" encoding="UTF-8"?>
< psys:request xmlns:psys="urn:iso:std:psys:request" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<id>BNZW0M00000DW</id>
<type>CR</type>
<format>MT</format>
<date>2017-04-26T12:21:13</date>
<signature></signature>
<content><![CDATA[{1:F01BNZWOMRXA0011111000000}{2:I102ACHMOMRXA001N}{3:{:113:0100}}{4:
:20:BNZW0M00000DW
:23:CREDIT
:26T:19
:21:BNZW0M00000DW001
:32B:OMR111,
:50K:/123124124
test
:52A:BNZWOMRXA001
:57A:BDOFOMRUA001
:59:/1231234124
test2
:70:
:77B:234234
1
1
:71A:SHA
:32A:170426OMR111,
-}]]></content>
< /psys:request>
签名后如下:
After Sign as below:
<?xml version="1.0" encoding="UTF-8"?>
< psys:request xmlns:psys="urn:iso:std:psys:request" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<id>BNZW0M00000DW</id>
<type>CR</type>
<format>MT</format>
<date>2017-04-26T12:21:13</date>
<signature>UjPx6Z1e7HLZWnhz1uz1LjQFnin/PMjkWDjADrDDOy0AOQdVbp5PwjoJQLzZzZmP5XCmoXKtByRqAzra57LzKdlQF7t4dXD6eG//rfnMvoRY4yOO/R3kuZLdMZ/bmy+nlhtZzRXtmGMoQTvTryC95berRm8liCs1hoiEZZ20ykAXXR45RaZuffWjTajF20/n8GJkSU9JSdtySr6rAOlV5Wi2hVD4v4Iqszka360w60NF4sNvpcwXt5EX1yx+o2GibDcBRDkW1Oo8r0IPCnuOQU/HWSks5K8aiTsAvqEP7SyKFbwLxSv3cQSWFbiWNQOX/Ejs3PPMBhRNxa3TA1tuVA==</signature>
<content><![CDATA[{1:F01BNZWOMRXA0011111000000}{2:I102ACHMOMRXA001N}{3:{:113:0100}}{4:
:20:BNZW0M00000DW
:23:CREDIT
:26T:19
:21:BNZW0M00000DW001
:32B:OMR111,
:50K:/123124124
test
:52A:BNZWOMRXA001
:57A:BDOFOMRUA001
:59:/1231234124
test2
:70:
:77B:234234
1
1
:71A:SHA
:32A:170426OMR111,
-}]]></content>
< /psys:request>
我尝试过:
我想使用RSA算法签名文件并验证签名。尝试了一个简单的文件,但没有用。
What I have tried:
I want to sign a file using RSA algorithm and verify the signature. Tried a simple file but didn't work.
推荐答案
不是仅限代码的解决方案,但您可以尝试Windows Signtool.exe 。
这是一篇关于它的文章,其中也提到了RSA: [ 5个代码示例]
Not a code only solution, but you could try the Windows Signtool.exe.
Here is an article about it where RSA is also mentioned: [5 Code Sign Examples]
这篇关于如何使用RSA算法签署文件并使用C#验证ASP.NET中的签名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!