【发布时间】:2014-11-10 08:34:28
【问题描述】:
我编写了一个程序来加密和解密 app.config 文件中的 appdata。该程序运行正常,所以我可以像这样加密app.config
<configProtectedData>
<providers>
<add keyContainerName="MyConfigurationKey"
description="Uses RsaCryptoServiceProvider to encrypt and decrypt"
name="MyProtectedConfigurationprovider"
type="System.Configuration.RsaProtectedConfigurationProvider,System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</providers>
</configProtectedData>
<appSettings configProtectionProvider="MyRSAProtectedConfigurationprovider">
<EncryptedData Type="http://www.w3.org/2001/04/xmlenc#Element"
xmlns="http://www.w3.org/2001/04/xmlenc#">
<EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#tripledes-cbc" />
<KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
<EncryptedKey xmlns="http://www.w3.org/2001/04/xmlenc#">
<EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-1_5" />
<KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
<KeyName>Rsa Key</KeyName>
</KeyInfo>
<CipherData>
<CipherValue> Some long text </CipherValue>
</CipherData>
</EncryptedKey>
</KeyInfo>
<CipherData>
<CipherValue> very long text</CipherValue>
</CipherData>
</EncryptedData>
</appSettings>
之后我导出了key.Result 这是这样的:
<RSAKeyValue>
<Modulus>Some text</Modulus>
<Exponent>AQAB</Exponent>
<P>Some text</P>
<Q>Some text</Q>
<DP>Some text</DP>
<DQ>Some text</DQ>
<InverseQ>Some text</InverseQ>
<D>Some text</D>
</RSAKeyValue>
现在,我需要在加密中找到私钥和公钥。我搜索了几个地方,但找不到合适的文档。请帮我解决这个问题。
【问题讨论】:
-
您在搜索时发现了什么?为什么您发现的内容不适用于这里?您是否在 MSDN 中查找过与加密相关的 API?
-
我使用以下问题的答案来执行此操作。 social.msdn.microsoft.com/Forums/en-US/…我找到了如何导出,但是我找不到描述哪个部分是私钥,哪个部分是公钥的文档
-
我在这里找到了答案。但我不确定它是否正确stackoverflow.com/questions/17693289/…
标签: c# encryption web-config rsa rsacryptoserviceprovider