Namespace: System.Security.Cryptography
RSACryptoServiceProvider
Performs asymmetric encryption and decryption using the implementation of the RSA algorithm provided by the cryptographic service provider (CSP). This class cannot be inherited.
Methods (5)
RSACryptoServiceProvider(Int32)Constructor
Initializes a new instance of the RSACryptoServiceProvider class with the specified key size.
| Parameter | Description |
|---|---|
| dwKeySize | The size of the key to use in bits. |
byte[] Encrypt(Byte[],Boolean)
Encrypts data with the RSA algorithm.
| Parameter | Description |
|---|---|
| rgb | The data to be encrypted. |
| fOAEP | true to perform direct RSA encryption using OAEP padding (only available on a computer running Windows XP or later); otherwise, false to use PKCS#1 v1.5 padding. |
Returns: The encrypted data.
byte[] Decrypt(Byte[],Boolean)
Decrypts data with the RSA algorithm.
| Parameter | Description |
|---|---|
| rgb | The data to be decrypted. |
| fOAEP | true to perform direct RSA decryption using OAEP padding (only available on a computer running Microsoft Windows XP or later); otherwise, false to use PKCS#1 v1.5 padding. |
Returns: The decrypted data, which is the original plain text before encryption.
byte[] SignHash(Byte[],String)
Computes the signature for the specified hash value by encrypting it with the private key.
| Parameter | Description |
|---|---|
| rgbHash | The hash value of the data to be signed. |
| str | The hash algorithm identifier (OID) used to create the hash value of the data. |
Returns: The RSA signature for the specified hash value.
bool VerifyHash(Byte[],String,Byte[])
Verifies that a digital signature is valid by determining the hash value in the signature using the provided public key and comparing it to the provided hash value.
| Parameter | Description |
|---|---|
| rgbHash | The hash value of the signed data. |
| str | The hash algorithm identifier (OID) used to create the hash value of the data. |
| rgbSignature | The signature data to be verified. |
Returns: true if the signature is valid; otherwise, false.