问题描述
我需要您的帮助密码学.我有一些密钥是在openssl和nbsp;中生成的我需要生成密钥签名loike" .pem.文件来自另一个键.这将加密我的文本.我不想得到它 在xml中.是RSAC
例如xml中的结果是这样的 .
-------------------------------------------------- ----------------------------
< RSAKeyValue>
<模量> xSFUXcDCAJJ3v3J87W7w92OuZ7JKuVv4Jpv0wkudbNKzd61HQPvbddq2dHWSxdjtbnqCbSiqnft5 + BfuY4A81v4ZukIxwPza70jgGCb0dLToePteQdaUDxAoJToO5IqfkfeqinKuYKaGT35CrWzr27GQqWYc7QeuQkrJ6EHdJ3E = LT;/模量>
<指数> AQAB</指数>
< P> 4 + Y3AWv5yta + Pe4VfDWAyZrBuY09ZZUAtqEu/DLvQF6F3DECh2JZM7eVff03Ffiw2TdYYvAnuuQicTCcMkVwPw ==</P>
< Q> 3W/ee5qV12ayXLL1D/UCbWBQLEKp/vgicc9DtunVNT/5wdfMP1WZTW/csbiVmBKzc48olC9QFbZ8AzHEX698Tw ==</Q>
< DP> AL6Bs3l8yVLGMEGUxGEQWJguxcJWTvybkf0YwC4SZe1pFnz6eyKxE + Anls + 63FGBklQB7 + DE4HFaQ3BbMjbT1Q ==</DP>
< DQ> vBvBWy0Z5071a + wWZETVmAa + dKr48IDn + diBhIwls8OyLqpcdt0HixHg4BSW + AXC7gMKDMAYfylzNd98G3De3w ==</DQ>
< InverseQ> THgQutS7iiFQ0jDRroujpA5DfSfkQu8amv6bYD56zg61f4adm4zf6nTDOrut3i7GXxdKK + 7PoRcbXdXmq6wO9Q ==</InverseQ>
< d取代; KT6f + D2sWZJLm7LIkKT1pc0lYGzdVYr4kJtwynYnqe0rv45xqhcIA9CO/C7dVqfchZD8WPp5ODS1gEMBja/3CmZ8SK04LEtZSHgMmTwZpH1Efpzz + 9H/ujvxI1k4r521a7F1NV71YHZRMtyMfTlynYhpA6y1OyEa6tyhLLKRVEE = LT;/d取代;
</RSAKeyValue>
-------------------------------------------------- -------------------------
我的档案是
-------------------------------------------------- -------------------------
----- BEGIN RSA私钥-----
MIICXgIBAAKBKBgQDrM2IL88xRluJMeTKmWSI45MHvKhJszCEA4YCCeGp8GlAe5LGj
pVr/4Zat2ARZSYX5J/LB8mwUJA81jCuEVDrW + uwnuH2Xg/Q + fzNCcc47I/E5GygU
t4mqkbzjq5RtXN/ePfUUxAUV68SwW8BmRLZKXoxTBL/RLMK/ub1f1cclJQIDAQAB
AoGBAKenzPAwLSjLoSxaCFzDlL1xczyEhPXA3JXAKNbX9y/Xod0jr + yy5hcYO0xY
e2EaI8HjVAwkPh5tRdopvKtrTzSpPXFiO7xRG5suwscMn2BAzl2EIuAVXcajmy5c
LJI7vNQeQzMA + D2xAuYFUv7jXtKVWWVIg2blcFifOsV + yrxRAkEA/sdRzjGOLDYW
aaN18HaNtL5RXUEjc7rm6HUGLvxKHo1LN9O0sIr1oCOHlEVA + Salm + X/7CLc + gWd
i9hF1OEcwwJBAOxUCUZagu02q17DQaAavGeOc3dRjv9i2omvOka4uBOP + N4nEUYd
nEnI + ILHeAds4 + NanxpoIXUueAp/elqXt/cCQGRtWvClFf6VX2ZKmY2snZT2RAo3
R + sxbB2LK2HP7sN2PIUH/Txtuf5ioumuFrtfIX5/Pc7tux8OoZhjKruL9JMCQQCj
+ hdJYooPz + wOX4rMbWCmtfe2JbgDyfJ6sEPOSGMo56 + 1bQQWU3ta0wBjtcW52Tsy
SHG23 + O/LBQMrLEX5Me3AkEAvnLkZeoH36ZUMqsGinWe0FeN7rLl4CMSP3U1xy5i
vvpKMzz0mceo4CWKJrwWfZuQQmxgjCdqEiWSzxfCGSDkew ==
-----结束RSA私钥-----
-------------------------------------------------- --------------------
请问我该如何解决这个问题.任何需要我的建议的人.
i need your help in cryptography . i have keys wich were generated in openssl and i need generete the key signature loike ".pem. file from another key . which will encrypt my text . i don't want to get it in xml . it is RSAC
for example the result in xml is like that .
------------------------------------------------------------------------------
<RSAKeyValue>
<Modulus>xSFUXcDCAJJ3v3J87W7w92OuZ7JKuVv4Jpv0wkudbNKzd61HQPvbddq2dHWSxdjtbnqCbSiqnft5+BfuY4A81v4ZukIxwPza70jgGCb0dLToePteQdaUDxAoJToO5IqfkfeqinKuYKaGT35CrWzr27GQqWYc7QeuQkrJ6EHdJ3E=</Modulus>
<Exponent>AQAB</Exponent>
<P>4+Y3AWv5yta+Pe4VfDWAyZrBuY09ZZUAtqEu/DLvQF6F3DECh2JZM7eVff03Ffiw2TdYYvAnuuQicTCcMkVwPw==</P>
<Q>3W/ee5qV12ayXLL1D/UCbWBQLEKp/vgicc9DtunVNT/5wdfMP1WZTW/csbiVmBKzc48olC9QFbZ8AzHEX698Tw==</Q>
<DP>AL6Bs3l8yVLGMEGUxGEQWJguxcJWTvybkf0YwC4SZe1pFnz6eyKxE+Anls+63FGBklQB7+DE4HFaQ3BbMjbT1Q==</DP>
<DQ>vBvBWy0Z5071a+wWZETVmAa+dKr48IDn+diBhIwls8OyLqpcdt0HixHg4BSW+AXC7gMKDMAYfylzNd98G3De3w==</DQ>
<InverseQ>THgQutS7iiFQ0jDRroujpA5DfSfkQu8amv6bYD56zg61f4adm4zf6nTDOrut3i7GXxdKK+7PoRcbXdXmq6wO9Q==</InverseQ>
<D>KT6f+D2sWZJLm7LIkKT1pc0lYGzdVYr4kJtwynYnqe0rv45xqhcIA9CO/C7dVqfchZD8WPp5ODS1gEMBja/3CmZ8SK04LEtZSHgMmTwZpH1Efpzz+9h/ujvxI1k4r521a7F1NV71YHZRMtyMfTlynYhpA6y1OyEa6tyhLLKRVEE=</D>
</RSAKeyValue>
---------------------------------------------------------------------------
the file that i have is
---------------------------------------------------------------------------
-----BEGIN RSA PRIVATE KEY-----
MIICXgIBAAKBgQDrM2IL88xRluJMeTKmWSI45MHvKhJszCEA4YCCeGp8GlAe5LGj
pVr/4Zat2ARZSYX5J/LB8mwUJA81jCuEVDrW+uwnuH2Xg/Q+fzNCcc47I/E5GygU
t4mqkbzjq5RtXN/ePfUUxAUV68SwW8BmRLZKXoxTBL/RLMK/ub1f1cclJQIDAQAB
AoGBAKenzPAwLSjLoSxaCFzDlL1xczyEhPXA3JXAKNbX9y/Xod0jr+yy5hcYO0xY
e2EaI8HjVAwkPh5tRdopvKtrTzSpPXFiO7xRG5suwscMn2BAzl2EIuAVXcajmy5c
LJI7vNQeQzMA+D2xAuYFUv7jXtKVWWVIg2blcFifOsV+yrxRAkEA/sdRzjGOLDYW
aaN18HaNtL5RXUEjc7rm6HUGLvxKHo1LN9O0sIr1oCOHlEVA+Salm+X/7CLc+gWd
i9hF1OEcwwJBAOxUCUZagu02q17DQaAavGeOc3dRjv9i2omvOka4uBOP+N4nEUYd
nEnI+ILHeAds4+NanxpoIXUueAp/elqXt/cCQGRtWvClFf6VX2ZKmY2snZT2RAo3
R+sxbB2LK2HP7sN2PIUH/Txtuf5ioumuFrtfIX5/Pc7tux8OoZhjKruL9JMCQQCj
+hdJYooPz+wOX4rMbWCmtfe2JbgDyfJ6sEPOSGMo56+1bQQWU3ta0wBjtcW52Tsy
SHG23+O/LBQMrLEX5Me3AkEAvnLkZeoH36ZUMqsGinWe0FeN7rLl4CMSP3U1xy5i
vvpKMzz0mceo4CWKJrwWfZuQQmxgjCdqEiWSzxfCGSDkew==
-----END RSA PRIVATE KEY-----
----------------------------------------------------------------------
please how i can slove this problem . anyone who can i need your soggestions .
推荐答案
如何获取OpenSSL是.key和.crt文件中的.pem文件?
var bytesToDecrypt = Convert.FromBase64String("la0Cz.....D43g=="); // string to decrypt, base64 encoded
AsymmetricCipherKeyPair keyPair;
using (var reader = File.OpenText(@"c:\myprivatekey.pem")) // file containing RSA PKCS1 private key
keyPair = (AsymmetricCipherKeyPair) new PemReader(reader).ReadObject();
var decryptEngine = new Pkcs1Encoding(new RsaEngine());
decryptEngine.Init(false, keyPair.Private);
var decrypted = Encoding.UTF8.GetString(decryptEngine.ProcessBlock(bytesToDecrypt, 0, bytesToDecrypt.Length));
这篇关于C#,RSAC,pem文件,RSA的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!