예제 #1
0
파일: RSA.cs 프로젝트: hankuikuide/Fm
        /// <summary>
        /// The get public key.
        /// </summary>
        /// <returns>
        /// The <see cref="RsaPublicKey"/>.
        /// </returns>
        public RsaPublicKey GetPublicKey()
        {
            var publicKey = new RsaPublicKey()
            {
                Exponent = BytesToHexString(rsap.Exponent),
                Modulus  = BytesToHexString(rsap.Modulus)
            };

            return(publicKey);
        }
예제 #2
0
파일: RSA.cs 프로젝트: hankuikuide/Fm
        /// <summary>
        /// RSA 的密钥产生 产生私钥 和公钥
        /// </summary>
        /// <param name="publicKey">
        /// The public Key.
        /// </param>
        /// <param name="xmlPrivateKey">
        /// The xml Private Key.
        /// </param>
        public void RSAKey(RsaPublicKey publicKey, out string xmlPrivateKey)
        {
            using (var rsa = new RSACryptoServiceProvider())
            {
                rsa.ImportParameters(rsap);
                xmlPrivateKey = rsa.ToXmlString(true);

                publicKey.Exponent = BytesToHexString(rsap.Exponent);
                publicKey.Modulus  = BytesToHexString(rsap.Modulus);
            }
        }