コード例 #1
0
        public static ICryptoValue EncryptByPrivateKey(byte[] originalData, string privateKey, RsaKeyFormat format, RSAEncryptionPadding padding)
        {
            var key      = RsaKeyGenerator.GeneratePrivateKey(privateKey, format);
            var function = Factory.Create(key);

            return(function.EncryptByPrivateKey(originalData, padding));
        }
コード例 #2
0
        public static ICryptoValue DecryptByPublicKey(byte[] cipherData, string publicKey, RsaKeyFormat format, bool fOEAP)
        {
            var key      = RsaKeyGenerator.GeneratePublicKey(publicKey, format);
            var function = Factory.Create(key);

            return(function.DecryptByPublicKey(cipherData));
        }
コード例 #3
0
        public static ICryptoValue EncryptByPrivateKey(string originalText, string privateKey, RsaKeyFormat format, RSAEncryptionPadding padding, Encoding encoding = null)
        {
            var key      = RsaKeyGenerator.GeneratePrivateKey(privateKey, format);
            var function = Factory.Create(key);

            return(function.EncryptByPrivateKey(originalText, padding, encoding));
        }
コード例 #4
0
        public static ICryptoValue EncryptByPublicKey(byte[] originalData, string publicKey, RsaKeyFormat format, bool fOEAP)
        {
            var key      = RsaKeyGenerator.GeneratePublicKey(publicKey, format);
            var function = Factory.Create(key);

            return(function.EncryptByPublicKey(originalData, fOEAP));
        }
コード例 #5
0
        public static ICryptoValue EncryptByPublicKey(string originalText, string publicKey, RsaKeyFormat format, bool fOEAP, Encoding encoding = null)
        {
            var key      = RsaKeyGenerator.GeneratePublicKey(publicKey, format);
            var function = Factory.Create(key);

            return(function.EncryptByPublicKey(originalText, fOEAP, encoding));
        }
コード例 #6
0
 /// <summary>
 /// Generate RSA private key.
 /// </summary>
 /// <param name="keySize"></param>
 /// <param name="keyFormat"></param>
 /// <param name="keepingFormat"></param>
 /// <returns></returns>
 public static RsaKey GeneratePublicKey(RsaKeySize keySize, RsaKeyFormat keyFormat = RsaKeyFormat.XML, bool keepingFormat = false) => Factory.GeneratePublicKey(keySize, keyFormat, keepingFormat);
コード例 #7
0
 /// <summary>
 /// Generate RSA key.
 /// </summary>
 /// <param name="mode"></param>
 /// <param name="keySize"></param>
 /// <param name="keyFormat"></param>
 /// <param name="keepingFormat"></param>
 /// <returns></returns>
 public static RsaKey GenerateKey(AsymmetricKeyMode mode, RsaKeySize keySize, RsaKeyFormat keyFormat = RsaKeyFormat.XML, bool keepingFormat = false) => Factory.GenerateKey(mode, keySize, keyFormat, keepingFormat);
コード例 #8
0
 /// <summary>
 /// Get public key of xml format from certificate file.
 /// </summary>
 /// <param name="certFile">The string path of certificate file.</param>
 /// <returns>String public key of xml format.</returns>
 public static RsaKey GeneratePublicKeyFromFile(string certFile) => Factory.GeneratePublicKeyFromFile(certFile);
コード例 #9
0
 /// <summary>
 /// Get private key of xml format from certificate file.
 /// </summary>
 /// <param name="certFile">The string path of certificate file.</param>
 /// <param name="password">The string password of certificate file.</param>
 /// <returns>String private key of xml format.</returns>
 public static RsaKey GeneratePrivateKeyFromFile(string certFile, string password) => Factory.GeneratePrivateKeyFromFile(certFile, password);
コード例 #10
0
 /// <summary>
 /// Generate Pkcs8 format RSA private key.
 /// </summary>
 /// <param name="key"></param>
 /// <returns></returns>
 public static RsaKey GeneratePrivateKeyInPkcs8(string key) => Factory.GeneratePrivateKeyInPkcs8(key);
コード例 #11
0
 /// <summary>
 /// Generate Pkcs8 format RSA private key.
 /// </summary>
 /// <param name="keySize">Key Size.Unit: bits</param>
 /// <param name="keepingFormat">Whether the format is true If it is standard pem file format</param>
 /// <returns></returns>
 public static RsaKey GeneratePrivateKeyInPkcs8(RsaKeySize keySize, bool keepingFormat) => Factory.GeneratePrivateKeyInPkcs8(keySize, keepingFormat);
コード例 #12
0
 /// <summary>
 /// Generate XML Format RSA public key.
 /// </summary>
 /// <returns></returns>
 public static RsaKey GeneratePublicKeyInXml() => Factory.GeneratePublicKeyInXml();
コード例 #13
0
 /// <summary>
 /// Generate XML Format RSA public key.
 /// </summary>
 /// <param name="key"></param>
 /// <returns></returns>
 public static RsaKey GeneratePublicKeyInXml(string key) => Factory.GeneratePublicKeyInXml(key);
コード例 #14
0
 /// <summary>
 /// Generate JSON Format RSA private key.
 /// </summary>
 /// <param name="key"></param>
 /// <returns></returns>
 public static RsaKey GeneratePrivateKeyInJson(string key) => Factory.GeneratePrivateKeyInJson(key);
コード例 #15
0
 /// <summary>
 /// Generate Pkcs1 format RSA public key.
 /// </summary>
 /// <param name="key"></param>
 /// <returns></returns>
 public static RsaKey GeneratePublicKeyInPkcs1(string key) => Factory.GeneratePublicKeyInPkcs1(key);
コード例 #16
0
 /// <summary>
 /// Generate JSON Format RSA private key.
 /// </summary>
 /// <param name="keySize"></param>
 /// <returns></returns>
 public static RsaKey GeneratePrivateKeyInJson(RsaKeySize keySize) => Factory.GeneratePrivateKeyInJson(keySize);
コード例 #17
0
 /// <summary>
 /// Generate JSON Format RSA private key.
 /// </summary>
 /// <returns></returns>
 public static RsaKey GeneratePrivateKeyInJson() => Factory.GeneratePrivateKeyInJson();
コード例 #18
0
 /// <summary>
 /// Generate JSON Format RSA public key.
 /// </summary>
 /// <param name="keySize"></param>
 /// <returns></returns>
 public static RsaKey GeneratePublicKeyInJson(int keySize) => Factory.GeneratePublicKeyInJson(keySize);
コード例 #19
0
 /// <summary>
 /// Generate JSON Format RSA Key.
 /// </summary>
 /// <param name="mode"></param>
 /// <param name="keySize">Key Size.Unit: bits</param>
 /// <returns></returns>
 public static RsaKey GenerateKeyInJson(AsymmetricKeyMode mode, RsaKeySize keySize) => Factory.GenerateKeyInJson(mode, keySize);
コード例 #20
0
 /// <summary>
 /// Generate XML Format RSA private key.
 /// </summary>
 /// <param name="keySize"></param>
 /// <returns></returns>
 public static RsaKey GeneratePrivateKeyInXml(int keySize) => Factory.GeneratePrivateKeyInXml(keySize);
コード例 #21
0
 /// <summary>
 /// Generate Pkcs1 format RSA private key.
 /// </summary>
 /// <param name="keepingFormat">Whether the format is true If it is standard pem file format</param>
 /// <returns></returns>
 public static RsaKey GeneratePrivateKeyInPkcs1(bool keepingFormat) => Factory.GeneratePrivateKeyInPkcs1(keepingFormat);
コード例 #22
0
 /// <summary>
 /// Generate XML Format RSA public key.
 /// </summary>
 /// <param name="keySize"></param>
 /// <returns></returns>
 public static RsaKey GeneratePublicKeyInXml(RsaKeySize keySize) => Factory.GeneratePublicKeyInXml(keySize);
コード例 #23
0
 /// <summary>
 /// Generate Pkcs8 format RSA key.
 /// </summary>
 /// <param name="mode"></param>
 /// <param name="keySize">Key Size.Unit: bits</param>
 /// <param name="keepingFormat">Whether the format is true If it is standard pem file format</param>
 /// <returns></returns>
 public static RsaKey GenerateKeyInPkcs8(AsymmetricKeyMode mode, RsaKeySize keySize, bool keepingFormat) => Factory.GenerateKeyInPkcs8(mode, keySize, keepingFormat);
コード例 #24
0
 /// <summary>
 /// Generate Pkcs8 format RSA public key.
 /// </summary>
 /// <param name="keySize"></param>
 /// <param name="keepingFormat"></param>
 /// <returns></returns>
 public static RsaKey GeneratePublicKeyInPkcs8(int keySize, bool keepingFormat) => Factory.GeneratePublicKeyInPkcs8(keySize, keepingFormat);
コード例 #25
0
 /// <summary>
 /// Generate RSA private key.
 /// </summary>
 /// <param name="key"></param>
 /// <param name="keyFormat"></param>
 /// <returns></returns>
 public static RsaKey GeneratePublicKey(string key, RsaKeyFormat keyFormat = RsaKeyFormat.XML) => Factory.GeneratePublicKey(key, keyFormat);
コード例 #26
0
 /// <summary>
 /// Generate XML Format RSA Key.
 /// </summary>
 /// <param name="mode"></param>
 /// <param name="keySize">Key Size.Unit: bits</param>
 /// <returns></returns>
 public static RsaKey GenerateKeyInXml(AsymmetricKeyMode mode, int keySize) => Factory.GenerateKeyInXml(mode, keySize);