Class RsaCrypto
RSA-based cryptographic functions.
Inheritance
Namespace: FM.LiveSwitch
Assembly: FM.LiveSwitch.dll
Syntax
public class RsaCrypto : object
Properties
DefaultKeySize
Gets or sets the default key length.
Declaration
public static int DefaultKeySize { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
Methods
CreateKey()
Creates an RSA key.
Declaration
public static RsaKey CreateKey()
Returns
Type | Description |
---|---|
RsaKey | An RSA key. |
CreateKey(Int32)
Creates an RSA key.
Declaration
public static RsaKey CreateKey(int keySize)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | keySize | The key size. |
Returns
Type | Description |
---|---|
RsaKey | An RSA key. |
Decrypt(Byte[], RsaKey)
Decrypts a value using a specified private key.
Declaration
public static byte[] Decrypt(byte[] data, RsaKey privateKey)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | data | The input byte array. |
RsaKey | privateKey | The private key. |
Returns
Type | Description |
---|---|
System.Byte[] | The output byte array. |
Encrypt(Byte[], RsaKey)
Encrypts a value using a specified public key.
Declaration
public static byte[] Encrypt(byte[] data, RsaKey publicKey)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | data | The input byte array. |
RsaKey | publicKey | The public key. |
Returns
Type | Description |
---|---|
System.Byte[] | The output byte array. |
SignMd5Sha1(Byte[], RsaKey)
Signs an MD5/SHA-1 hash using a specified key.
Declaration
public static byte[] SignMd5Sha1(byte[] md5Sha1, RsaKey privateKey)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | md5Sha1 | The MD5/SHA-1 hash. |
RsaKey | privateKey | The private key. |
Returns
Type | Description |
---|---|
System.Byte[] | The output byte array. |
SignSha1(Byte[], RsaKey)
Signs a SHA-1 hash using a specified key.
Declaration
public static byte[] SignSha1(byte[] sha1, RsaKey privateKey)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | sha1 | The SHA-1 hash. |
RsaKey | privateKey | The private key. |
Returns
Type | Description |
---|---|
System.Byte[] | The output byte array. |
SignSha256(Byte[], RsaKey)
Signs a SHA-256 hash using a specified key.
Declaration
public static byte[] SignSha256(byte[] sha256, RsaKey privateKey)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | sha256 | The SHA-256 hash. |
RsaKey | privateKey | The private key. |
Returns
Type | Description |
---|---|
System.Byte[] | The output byte array. |
VerifyMd5Sha1(Byte[], Byte[], RsaKey)
Verifies an MD5/SHA-1 hash using a specified key and signature.
Declaration
public static bool VerifyMd5Sha1(byte[] md5Sha1, byte[] signature, RsaKey publicKey)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | md5Sha1 | The MD5/SHA-1 hash. |
System.Byte[] | signature | The input signature. |
RsaKey | publicKey | The public key. |
Returns
Type | Description |
---|---|
System.Boolean |
|
VerifySha1(Byte[], Byte[], RsaKey)
Verifies a signature using a specified key and SHA-1 hash.
Declaration
public static bool VerifySha1(byte[] sha1, byte[] signature, RsaKey publicKey)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | sha1 | The SHA-1 hash. |
System.Byte[] | signature | The input signature. |
RsaKey | publicKey | The public key. |
Returns
Type | Description |
---|---|
System.Boolean |
|
VerifySha256(Byte[], Byte[], RsaKey)
Verifies a signature using a specified key and SHA-256 hash.
Declaration
public static bool VerifySha256(byte[] sha256, byte[] signature, RsaKey publicKey)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | sha256 | The SHA-256 hash. |
System.Byte[] | signature | The input signature. |
RsaKey | publicKey | The public key. |
Returns
Type | Description |
---|---|
System.Boolean |
|