← Interactive API Explorer
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.
ParameterDescription
dwKeySizeThe size of the key to use in bits.
byte[] Encrypt(Byte[],Boolean)
Encrypts data with the RSA algorithm.
ParameterDescription
rgbThe data to be encrypted.
fOAEPtrue 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.
ParameterDescription
rgbThe data to be decrypted.
fOAEPtrue 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.
ParameterDescription
rgbHashThe hash value of the data to be signed.
strThe 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.
ParameterDescription
rgbHashThe hash value of the signed data.
strThe hash algorithm identifier (OID) used to create the hash value of the data.
rgbSignatureThe signature data to be verified.
Returns: true if the signature is valid; otherwise, false.