RSACrypto |
public sealed class RSACryptoServiceProvider : RSA
The RSACryptoServiceProvider type exposes the following members.
| Name | Description | |
|---|---|---|
| RSACryptoServiceProvider | Initializes a new instance of the Crestron.SimplSharp.Cryptography.RSACryptoServiceProvider class using the default key. | |
| RSACryptoServiceProvider(CspParameters) | Initializes a new instance of the Crestron.SimplSharp.Cryptography.RSACryptoServiceProvider class with the specified parameters. | |
| RSACryptoServiceProvider(Int32) | Initializes a new instance of the Crestron.SimplSharp.Cryptography.RSACryptoServiceProvider class with the specified key size. | |
| RSACryptoServiceProvider(Int32, CspParameters) | Initializes a new instance of the Crestron.SimplSharp.Cryptography.RSACryptoServiceProvider class with the specified key size and parameters. |
| Name | Description | |
|---|---|---|
| CspKeyContainerInfo | Gets a Crestron.SimplSharp.Cryptography.CspKeyContainerInfo object that describes additional information about a cryptographic key pair. | |
| KeyExchangeAlgorithm |
Gets the name of the key exchange algorithm available with this implementation
of Crestron.SimplSharp.Cryptography.RSA.
(Overrides AsymmetricAlgorithmKeyExchangeAlgorithm) | |
| KeySize |
Gets the size of the current key.
(Overrides AsymmetricAlgorithmKeySize) | |
| LegalKeySizes |
Gets the key sizes that are supported by the asymmetric algorithm.
(Inherited from AsymmetricAlgorithm) | |
| PersistKeyInCsp | Gets or sets a value indicating whether the key should be persisted in the cryptographic service provider (CSP). | |
| PublicOnly | Gets a value that indicates whether the Crestron.SimplSharp.Cryptography.RSACryptoServiceProvider object contains only a public key. | |
| SignatureAlgorithm |
Gets the name of the signature algorithm available with this implementation
of Crestron.SimplSharp.Cryptography.RSA.
(Overrides AsymmetricAlgorithmSignatureAlgorithm) | |
| UseMachineKeyStore | Gets or sets a value indicating whether the key should be persisted in the computer's key store instead of the user profile store. |
| Name | Description | |
|---|---|---|
| Clear |
Releases all resources used by the Crestron.SimplSharp.Cryptography.AsymmetricAlgorithm class.
(Inherited from AsymmetricAlgorithm) | |
| Decrypt | Decrypts data with the Crestron.SimplSharp.Cryptography.RSA algorithm. | |
| DecryptValue |
This method is not supported in the current version.
(Overrides RSADecryptValue(Byte)) | |
| Dispose |
Dispose
(Inherited from AsymmetricAlgorithm) | |
| Dispose(Boolean) |
Required member to implement AsymmetricAlgorithm class.
(Overrides AsymmetricAlgorithmDispose(Boolean)) | |
| Encrypt | Encrypts data with the Crestron.SimplSharp.Cryptography.RSA algorithm. | |
| EncryptValue |
This method is not supported in the current version.
(Overrides RSAEncryptValue(Byte)) | |
| Equals | Determines whether the specified object is equal to the current object. (Inherited from Object) | |
| ExportCspBlob | Exports a blob containing the key information associated with an Crestron.SimplSharp.Cryptography.RSACryptoServiceProvider object. | |
| ExportParameters |
Exports the Crestron.SimplSharp.Cryptography.RSAParameters.
(Overrides RSAExportParameters(Boolean)) | |
| GetHashCode | Serves as the default hash function. (Inherited from Object) | |
| GetType | Gets the Type of the current instance. (Inherited from Object) | |
| ImportCspBlob | Imports a blob that represents RSA key information. | |
| ImportParameters |
Imports the specified Crestron.SimplSharp.Cryptography.RSAParameters.
(Overrides RSAImportParameters(RSAParameters)) | |
| SignData(Byte, Object) | Computes the hash value of the specified byte array using the specified hash algorithm, and signs the resulting hash value. | |
| SignData(Stream, Object) | Computes the hash value of the specified input stream using the specified hash algorithm, and signs the resulting hash value. | |
| SignData(Byte, Int32, Int32, Object) | Computes the hash value of a subset of the specified byte array using the specified hash algorithm, and signs the resulting hash value. | |
| SignHash | Computes the signature for the specified hash value by encrypting it with the private key. | |
| ToString | Returns a string that represents the current object. (Inherited from Object) | |
| VerifyData | Verifies the specified signature data by comparing it to the signature computed for the specified data. | |
| VerifyHash | Verifies the specified signature data by comparing it to the signature computed for the specified hash value. |
| Name | Description | |
|---|---|---|
| KeySizeValue |
Represents the size, in bits, of the key modulus used by the asymmetric algorithm.
(Inherited from AsymmetricAlgorithm) | |
| LegalKeySizesValue |
Specifies the key sizes that are supported by the asymmetric algorithm.
(Inherited from AsymmetricAlgorithm) |
public class EncryptionLayer { // keyStoreName identifies the persistent key container used // to store the RSA key pair string keyStoreName; public EncryptionLayer(string keyStoreName) { this.keyStoreName = keyStoreName; } public byte[] RSAEncrypt(string plaintext) { // retrieve RSA key pair from key container var csp = new CspParameters(); csp.KeyContainerName = keyStoreName; var rsa = new RSACryptoServiceProvider(csp); // encrypt the inputted string byte[] cipherbytes = rsa.Encrypt(Encoding.Default.GetBytes(plaintext), false); // return the encrypted bytes return cipherbytes; } public string RSADecrypt(byte[] ciphertext) { // retrieve RSA key pair from key container var csp = new CspParameters(); csp.KeyContainerName = keyStoreName; var rsa = new RSACryptoServiceProvider(csp); // decrypt the inputted byte array byte[] plainbytes = null; plainbytes = rsa.Decrypt(ciphertext, false); // convert the plaintext bytes back to a string and return it return Encoding.Default.GetString(plainbytes, 0, plainbytes.Length); } }