C# Class GonzoNet.Encryption.StaticStaticDiffieHellman

Contains methods for en/decryption and ex/importing keys. From: http://stackoverflow.com/questions/3196297/minimal-message-size-public-key-encryption-in-net
显示文件 Open project: Afr0Games/Project-Dollhouse Class Usage Examples

Public Methods

Method Description
Decrypt ( System.Security.Cryptography.ECDiffieHellmanCng privateKey, System.Security.Cryptography.ECDiffieHellmanPublicKey publicKey, byte nonce, byte encryptedData ) : byte[]

Decrypts the provided data.

Encrypt ( System.Security.Cryptography.ECDiffieHellmanCng privateKey, System.Security.Cryptography.ECDiffieHellmanPublicKey publicKey, byte nonce, byte data ) : byte[]

Encrypts the provided data.

ExportKey ( string Path, System.Security.Cryptography.CngKey PrivateKey ) : void

Exports a private key.

ExportKey ( string Path, System.Security.Cryptography.ECDiffieHellmanPublicKey Key ) : void
ExportKey ( string Path, byte Key ) : void
ImportKey ( string Path ) : byte[]

Imports a key from a specified path.

Private Methods

Method Description
DeriveKeyAndIv ( System.Security.Cryptography.ECDiffieHellmanCng privateKey, System.Security.Cryptography.ECDiffieHellmanPublicKey publicKey, byte nonce ) : Aes

Method Details

Decrypt() public static method

Decrypts the provided data.
public static Decrypt ( System.Security.Cryptography.ECDiffieHellmanCng privateKey, System.Security.Cryptography.ECDiffieHellmanPublicKey publicKey, byte nonce, byte encryptedData ) : byte[]
privateKey System.Security.Cryptography.ECDiffieHellmanCng The private key used for decryption.
publicKey System.Security.Cryptography.ECDiffieHellmanPublicKey The public key used for decryption.
nonce byte The nonce used for decryption.
encryptedData byte The data to decrypt.
return byte[]

Encrypt() public static method

Encrypts the provided data.
public static Encrypt ( System.Security.Cryptography.ECDiffieHellmanCng privateKey, System.Security.Cryptography.ECDiffieHellmanPublicKey publicKey, byte nonce, byte data ) : byte[]
privateKey System.Security.Cryptography.ECDiffieHellmanCng The private key used for encryption.
publicKey System.Security.Cryptography.ECDiffieHellmanPublicKey The public key used for encryption.
nonce byte The nonce used for encryption.
data byte The data to encrypt.
return byte[]

ExportKey() public static method

Exports a private key.
public static ExportKey ( string Path, System.Security.Cryptography.CngKey PrivateKey ) : void
Path string The path to export to.
PrivateKey System.Security.Cryptography.CngKey The key to export.
return void

ExportKey() public static method

public static ExportKey ( string Path, System.Security.Cryptography.ECDiffieHellmanPublicKey Key ) : void
Path string
Key System.Security.Cryptography.ECDiffieHellmanPublicKey
return void

ExportKey() public static method

public static ExportKey ( string Path, byte Key ) : void
Path string
Key byte
return void

ImportKey() public static method

Imports a key from a specified path.
public static ImportKey ( string Path ) : byte[]
Path string The path of the key.
return byte[]