public string Get(string str) { //2048 公钥 string publicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAoKefXtIqc293nDjFpCkjUuyEL3bc15lVlocJJVdQovRLyTKXpzcD029U0MeVAd8Hq9huQtxWspV+/KSoXjN5BGc7XS/QZItG1irxtivIHlFmzra7Fk94r10F4/hR/mdq+H/WAIJJjGpw1Garncvh8AEJXJ2JBbiAyM0zNSqDNidTFFPuLoGQQ+EGsbCESMFy0mGeSBd8/b6ADwLiRXuAiNo3ArFRui2fwuljXyFP2EC1aRNIF8qc5GkikBkqUPKQrQ29H2cfQEpbxj2LP4hOLmuO+U2snMN3DRyTMnONJWN10x08VlCsZUS9fHJnR6kkU5PYodpJQ8hI1Uloy7TH5wIDAQAB"; //2048 私钥 string privateKey = "MIIEpAIBAAKCAQEAoKefXtIqc293nDjFpCkjUuyEL3bc15lVlocJJVdQovRLyTKXpzcD029U0MeVAd8Hq9huQtxWspV+/KSoXjN5BGc7XS/QZItG1irxtivIHlFmzra7Fk94r10F4/hR/mdq+H/WAIJJjGpw1Garncvh8AEJXJ2JBbiAyM0zNSqDNidTFFPuLoGQQ+EGsbCESMFy0mGeSBd8/b6ADwLiRXuAiNo3ArFRui2fwuljXyFP2EC1aRNIF8qc5GkikBkqUPKQrQ29H2cfQEpbxj2LP4hOLmuO+U2snMN3DRyTMnONJWN10x08VlCsZUS9fHJnR6kkU5PYodpJQ8hI1Uloy7TH5wIDAQABAoIBAQCMHgYyxix+J57zotRF/Bcx8NTNLOcqJzLtqXLBnajXpygeH8EC90mf8/7OZPPCAQqIx6hLKi93bEmoAdhS6KPIwlyVRumDd7HdgvDzyLWuM6Lt8ZO0vrVshT5o+SBSOVKjz6MPKJMLI56qsa1GYBb7o3vNyhxC4At6lvXtjdmItVp+Bs01w2RzfWL3RMTBNHJ4guOCKRQQTFgl6K2Uug2g+I4hmOvqp+V+0IefONjW5+nenSjvGo24pC35BBuzJTxf/1c5j2VhHw7QZv2FiONgJDYd82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j7X4icRNeztGV4HpRgsViEz0PIO9juJvGLng4ERR4ubk3jLSK/+lVw94ZJ9BtN7FG7NOO0u5tGcDHuMU9aNLwFb3is8UAWul5yACaZxmE8eNjX+CdtxyYIMUIUp5pLRHqo/c6T0bZdBQtDBX/tdF2bGDPcsV0tO3fuwoeJq4w9mBlbVD8mVV1qN/2jXTiX0mAwF59YJwjugPv4FHmu88vQAaR9J/YG1bDRw+XZm07d/aJo84nxgTs+mzxm43tUWOhMwp0ZURxVzawIDAQAB"; var rsa = new RSAHelper(RSAType.RSA2, Encoding.UTF8, privateKey, publicKey, publicKeys, "asda"); // string str = "博客园 http://www.cnblogs.com/"; Console.WriteLine("原始字符串:" + str); //加密 string enStr = rsa.Encrypt(str); string enStrs = rsa.AppEncrypt(str); Console.WriteLine("加密字符串:" + enStr); //解密 string deStr = rsa.Decrypt(enStr); Console.WriteLine("解密字符串:" + deStr); //私钥签名 string signStr = rsa.Sign(str); Console.WriteLine("字符串签名:" + signStr); //公钥验证签名 bool signVerify = rsa.Verify(str, signStr); Console.WriteLine("验证签名:" + signVerify); return(deStr); // return RSAHelper.StringToBase64("abcsdeasdweixiao"); }