关于c#中rsa解密换成python代码

对c#不是很懂,但看代码 对PrivateKey这样的私钥格式就可以识别, 而python中只知道要类似PrivateKey2样的才能识别, 下面有一份c#代码不知道如何改写成python 求大神

string PrivateKey = "BwIAAACkAABSU0EyAAQAAAEAAQDdmDDrHcqxUxzfTGLCtOnOwvD76nh+1ctJBGGquK6G2YyrlLRB3ZVRr1dy5PTqoEnVipV/qBHYfiTyD2rce/wrYV/iGFj3ETywdlr/wvAzRNwahr8VMOrs7iJItoiDoIsHuVXwpwXpJdWar4v5Gg+I2rD13PjYXSgF6Mkn2ANWnL0htMboQqJUnitEiO79iLx+1S+pbBlgzunnkkoX3u3O+jUG9NZPKuNrJOsRct4mF1b3dHU9pwu/c9jNN7aaRMuhdSxkqb32hllyIWxJuAcHOmfyVpt9b0aY6lK4FfeTcVuXlNhTkyLIT70AYvZN4hGvU7iFLXQEpwG6Owt2kuTE3cFKo7gX1hQgigsbJ7v7DOR7Ga98l3t7S4v9UCiSNNrFHjAQ23zYcZbMXXrehor0BYKwuzqP7TJ/eA4EozS4PAHZC665GfqjWNjARNXoBRvLWftDGQOA495QZZsrYY+Pop0TDDLow0PuSp/3neZecQu2V1taUJK5ZdafRRx4I3dqz9DcW3mUuIx53Sgifqdeu6lOcz0g8Z/9SamuN7f5uaoy7dE3YbANajidcz+UIaEaxeO9v717GqQ2XnULu46bAe2ApEbCV3582NbbCiPCg2p3azB0WxQc6cZmLS8XgcRXEviSGr9tJz2V4mt2QJHnr10jUDXzXYfUklMPv6RusPdj8WuRzsbPJ5bgyWqQVP55g5k3SFRjBG8TF6DzTWuqPC6ShLtnkgQ93HJxkqYRn39PVi0/H1LbVMk4H5vTzw0=";//私钥

PrivateKey2 = """-----BEGIN RSA PRIVATE KEY-----
MIICXQIBAAKBgQDKoeRzRVf8WoRSDYYqUzThpYCr90jfdFwTSXHJ526K8C6TEwdT
UA+CFPQPRUg9jrYgFcown+J2myzO8BRLynD+XHb9ilLb49Mqk2CvDt/yK32lgHv3
QVx14Dpb6h8isjncSF965fxBxlHGbvPwnHkJ9etRIYdYV3QpYohFszH3wQIDAQAB
AoGAFhKqkw/ztK6biWClw8iKkyX3LURjsMu5F/TBK3BFb2cYe7bv7lhjSBVGPL+c
TfBU0IvvGXrhLXBb4jLu0w67Xhggwwfc86vlZ8eLcrmYVat7N6amiBmYsw20GViU
UFmePbo1G2BXqMA43JxqbIQwOLZ03zdw6GHj6EVlx369IAECQQD4K2R3K8ah50Yz
LhF7zbYPIPGbHw+crP13THiYIYkHKJWsQDr8SXoNQ96TQsInTXUAmF2gzs/AwdQg
gjIJ/dmBAkEA0QarqdWXZYbse1XIrQgBYTdVH9fNyLs1e1sBmNxlo4QMm/Le5a5L
XenorEjnpjw5YpEJFDS4ijUI3dSzylC+QQJARqcD6TGbUUioobWB4L9GD7SPVFxZ
c3+EgcxRoO4bNuCFDA8VO/InP1ONMFuXLt1MbCj0ru1yFCyamc63NEUDAQJBALt7
PjGgsKCRuj6NnOcGDSbDWIitKZhnwfqYkAApfsiBQkYGO0LLaDIeAWG2KoCB9/6e
lAQZnYPpOcCubWyDq4ECQQCrRDf0gVjPtipnPPS/sGN8m1Ds4znDDChhRlw74MI5
FydvHFumChPe1Dj2I/BWeG1gA4ymXV1tE9phskV3XZfq
-----END RSA PRIVATE KEY-----"""



using System;
using System.Web;
using System.Security.Cryptography;
using System.Text;

using System.Collections;
using System.IO;
using System.Xml.Serialization;
using System.Xml;
using System.Net;

namespace HelloWorld
{
    class Program
    {
        static void Main(string[] args)
        {
            //string Exponent = "AQAB";//摸
            //string Modulus = "nFYD2CfJ6AUoXdj43PWw2ogPGvmLr5rVJekFp/BVuQeLoIOItkgi7uzqMBW/hhrcRDPwwv9adrA8EfdYGOJfYSv8e9xqD/IkftgRqH+VitVJoOr05HJXr1GV3UG0lKuM2YauuKphBEnL1X546vvwws7ptMJiTN8cU7HKHeswmN0=";//公钥
            string outCryptText = "";
            string CryptText = "SiaZZW85CExq+2OEjfXiIldsivitxoS69xYlpTWrXyfFjU6GuIO+nmFYfdI06wDiKFU3Vcjoo5Nz2/7ooTFqEBVRun57GG6fw10c4BAkaMyUy2JiyLYnNtdDFv+sYdRuLfKW4cdNOeN0KEqMRZfPfmsGhYHIR2gYrS8kUZTG0Ds=";//加密
            string PrivateKey = "BwIAAACkAABSU0EyAAQAAAEAAQDdmDDrHcqxUxzfTGLCtOnOwvD76nh+1ctJBGGquK6G2YyrlLRB3ZVRr1dy5PTqoEnVipV/qBHYfiTyD2rce/wrYV/iGFj3ETywdlr/wvAzRNwahr8VMOrs7iJItoiDoIsHuVXwpwXpJdWar4v5Gg+I2rD13PjYXSgF6Mkn2ANWnL0htMboQqJUnitEiO79iLx+1S+pbBlgzunnkkoX3u3O+jUG9NZPKuNrJOsRct4mF1b3dHU9pwu/c9jNN7aaRMuhdSxkqb32hllyIWxJuAcHOmfyVpt9b0aY6lK4FfeTcVuXlNhTkyLIT70AYvZN4hGvU7iFLXQEpwG6Owt2kuTE3cFKo7gX1hQgigsbJ7v7DOR7Ga98l3t7S4v9UCiSNNrFHjAQ23zYcZbMXXrehor0BYKwuzqP7TJ/eA4EozS4PAHZC665GfqjWNjARNXoBRvLWftDGQOA495QZZsrYY+Pop0TDDLow0PuSp/3neZecQu2V1taUJK5ZdafRRx4I3dqz9DcW3mUuIx53Sgifqdeu6lOcz0g8Z/9SamuN7f5uaoy7dE3YbANajidcz+UIaEaxeO9v717GqQ2XnULu46bAe2ApEbCV3582NbbCiPCg2p3azB0WxQc6cZmLS8XgcRXEviSGr9tJz2V4mt2QJHnr10jUDXzXYfUklMPv6RusPdj8WuRzsbPJ5bgyWqQVP55g5k3SFRjBG8TF6DzTWuqPC6ShLtnkgQ93HJxkqYRn39PVi0/H1LbVMk4H5vTzw0=";//私钥

            CspParameters RSAParams = new CspParameters();
            RSAParams.Flags = CspProviderFlags.UseMachineKeyStore;
            System.Security.Cryptography.RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(1024, RSAParams);

            byte[] prikey = Convert.FromBase64String(PrivateKey); ;
            rsa.ImportCspBlob(prikey);

            byte[] cipherBytes = Convert.FromBase64String(CryptText);
            byte[] plainText = rsa.Decrypt(cipherBytes, false);

            outCryptText = Encoding.UTF8.GetString(plainText);
            Console.WriteLine(string.Join(",", prikey));
            Console.WriteLine(outCryptText);//ZLeDWyfLHE7qSFBD
            Console.ReadLine();

        }
    }
}
查看回复