首页新闻找找看学习计划

关于RSA的 pem 转xml

0
[已解决问题] 解决于 2016-09-09 14:45

c# rsa加密需要xml公钥  如何将pem格式转换成xml 

-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQD5MIb5ZQhNGhsUjfFbn7y6nY6tsqV9LcC2s/rLpu9sz8CplsTy2SuTG0o7y9ICXW6oRUC9bVxI8TfTK4bbSrNQ6UoExzQFdbc3pEGun3iCy+inBhIC6xf5Z7lN+WqTKCZ607iLwKh+wDdZc6U4x1rxF4vngk1sXIdnYEoGjpRNLQIDAQAB
-----END PUBLIC KEY-----

七页的主页 七页 | 菜鸟二级 | 园豆:210
提问于:2016-09-05 13:42
< >
分享
最佳答案
0

使用BouncyCastle组件

 1    /// <summary>    
 2       /// RSA公钥格式转换, 
 3       /// </summary>    
 4       /// <param name="publicKey">pem公钥</param>    
 5       /// <returns></returns>    
 6       public static string RSAPublicKeyJava2DotNet(string publicKey)
 7       {
 8           RsaKeyParameters publicKeyParam = (RsaKeyParameters)PublicKeyFactory.CreateKey(Convert.FromBase64String(publicKey));
 9           return string.Format("<RSAKeyValue><Modulus>{0}</Modulus><Exponent>{1}</Exponent></RSAKeyValue>",
10               Convert.ToBase64String(publicKeyParam.Modulus.ToByteArrayUnsigned()),
11               Convert.ToBase64String(publicKeyParam.Exponent.ToByteArrayUnsigned()));
12       }

 

奖励园豆:5
alci | 菜鸟二级 |园豆:228 | 2016-09-08 11:06
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册