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)); }
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)); }
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)); }
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)); }
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)); }
/// <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);
/// <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);
/// <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);
/// <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);
/// <summary> /// Generate Pkcs8 format RSA private key. /// </summary> /// <param name="key"></param> /// <returns></returns> public static RsaKey GeneratePrivateKeyInPkcs8(string key) => Factory.GeneratePrivateKeyInPkcs8(key);
/// <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);
/// <summary> /// Generate XML Format RSA public key. /// </summary> /// <returns></returns> public static RsaKey GeneratePublicKeyInXml() => Factory.GeneratePublicKeyInXml();
/// <summary> /// Generate XML Format RSA public key. /// </summary> /// <param name="key"></param> /// <returns></returns> public static RsaKey GeneratePublicKeyInXml(string key) => Factory.GeneratePublicKeyInXml(key);
/// <summary> /// Generate JSON Format RSA private key. /// </summary> /// <param name="key"></param> /// <returns></returns> public static RsaKey GeneratePrivateKeyInJson(string key) => Factory.GeneratePrivateKeyInJson(key);
/// <summary> /// Generate Pkcs1 format RSA public key. /// </summary> /// <param name="key"></param> /// <returns></returns> public static RsaKey GeneratePublicKeyInPkcs1(string key) => Factory.GeneratePublicKeyInPkcs1(key);
/// <summary> /// Generate JSON Format RSA private key. /// </summary> /// <param name="keySize"></param> /// <returns></returns> public static RsaKey GeneratePrivateKeyInJson(RsaKeySize keySize) => Factory.GeneratePrivateKeyInJson(keySize);
/// <summary> /// Generate JSON Format RSA private key. /// </summary> /// <returns></returns> public static RsaKey GeneratePrivateKeyInJson() => Factory.GeneratePrivateKeyInJson();
/// <summary> /// Generate JSON Format RSA public key. /// </summary> /// <param name="keySize"></param> /// <returns></returns> public static RsaKey GeneratePublicKeyInJson(int keySize) => Factory.GeneratePublicKeyInJson(keySize);
/// <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);
/// <summary> /// Generate XML Format RSA private key. /// </summary> /// <param name="keySize"></param> /// <returns></returns> public static RsaKey GeneratePrivateKeyInXml(int keySize) => Factory.GeneratePrivateKeyInXml(keySize);
/// <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);
/// <summary> /// Generate XML Format RSA public key. /// </summary> /// <param name="keySize"></param> /// <returns></returns> public static RsaKey GeneratePublicKeyInXml(RsaKeySize keySize) => Factory.GeneratePublicKeyInXml(keySize);
/// <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);
/// <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);
/// <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);
/// <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);