Exemple #1
0
        /// <summary>
        /// Creates an RSA key pair from PKCS8-formatted RSA private key string.
        /// </summary>
        public static RSA CreateKeyPairFromRsaPrivateKeyFormattedString(string privateKeyString)
        {
            var privateKeyStringTrimmed = privateKeyString
                                          .Replace("-----BEGIN RSA PRIVATE KEY-----\n", "")
                                          .Replace("\n-----END RSA PRIVATE KEY-----\n", "");

            return(RsaKeyUtils.DecodeRsaPrivateKey(Convert.FromBase64String(privateKeyStringTrimmed)));
        }
Exemple #2
0
        /// <summary>
        /// Creates an RSA key pair from PKCS8-formatted RSA private key string.
        /// </summary>
        public static RSA CreateKeyPairFromRsaPrivateKeyFormattedString(string privateKeyString)
        {
            var privateKeyStringTrimmed = privateKeyString
                                          .Replace(WINDOWS_NEWLINE, NEWLINE)
                                          .Replace(RSA_PRIVATE_KEY_START, String.Empty)
                                          .Replace(RSA_PRIVATE_KEY_END, String.Empty)
                                          .Trim();

            return(RsaKeyUtils.DecodeRsaPrivateKey(Convert.FromBase64String(privateKeyStringTrimmed)));
        }