/// <summary> /// 通过一个pem文件创建RSA,pem为公钥或私钥,出错抛异常 /// </summary> public RSA(string pem, bool noop) { _init(); rsa = RSA_PEM.FromPEM(pem); }
/// <summary> /// 导出PEM PKCS#8格式密钥对,如果convertToPublic含私钥的RSA将只返回公钥,仅含公钥的RSA不受影响 /// </summary> public string ToPEM_PKCS8(bool convertToPublic = false) { return(RSA_PEM.ToPEM(rsa, convertToPublic, true)); }
/// <summary> /// 设定服务器器的公钥 /// </summary> public void SetServerPublicKey(string publickey) { this.ServerPublicKey = publickey; this.ServerRSA = RSA_PEM.FromPEM(this.ServerPublicKey); }