Skip to content

Encrypt Method ​

Definition ​

  • Namespace: JASE.Crypto
  • Assembly: JASE.Crypto.dll

Overloads ​

NameDescription
byte[] Encrypt(byte[] input, byte[] publicKey, RsaPadding padding = null)Encrypts the specified data using an RSA public key in raw byte array format.
byte[] Encrypt(byte[] input, string keyInXml, RsaPadding padding = null)Encrypts the specified data using an RSA public key provided in XML format.
byte[] Encrypt(byte[] input, X509Certificate2 certificate, RsaPadding padding = null, bool allowInvalidTime = null)Encrypts the input data using the public key of the specified X.509 certificate.

byte[] Encrypt(byte[] input, byte[] publicKey, RsaPadding padding = null) ​

csharp
byte[] Encrypt(byte[] input, byte[] publicKey, RsaPadding padding = null)

Encrypts the specified data using an RSA public key in raw byte array format.

Parameters ​

NameDescription
inputThe plaintext input data to encrypt.
paddingThe RSA padding scheme to use. Default is OaepSHA256.
publicKeyThe RSA public key used for encryption, provided as a byte array.

Returns ​

A byte array containing the encrypted data.

byte[] Encrypt(byte[] input, X509Certificate2 certificate, RsaPadding padding = null, bool allowInvalidTime = null) ​

csharp
byte[] Encrypt(byte[] input, X509Certificate2 certificate, RsaPadding padding = null, bool allowInvalidTime = null)

Encrypts the input data using the public key of the specified X.509 certificate.

Parameters ​

NameDescription
allowInvalidTimeBoolean to enforce certificate time frame validity
certificateThe X.509 certificate containing the public key used for encryption.
inputThe input data to encrypt.
paddingThe RSA padding scheme to use. Default is OaepSHA256.

Returns ​

The encrypted data.

byte[] Encrypt(byte[] input, string keyInXml, RsaPadding padding = null) ​

csharp
byte[] Encrypt(byte[] input, string keyInXml, RsaPadding padding = null)

Encrypts the specified data using an RSA public key provided in XML format.

Parameters ​

NameDescription
inputThe plaintext input data to encrypt.
keyInXmlThe RSA public key in XML format. Must be a valid XML string.
paddingThe RSA padding scheme to use. Default is OaepSHA256.

Returns ​

A byte array containing the encrypted data.