C# Class MGDF.GamesManager.Common.DPAPI

Encrypts and decrypts data using DPAPI functions.
ファイルを表示 Open project: mrsharpoblunto/MGDF

Public Methods

Method Description
Decrypt ( byte cipherTextBytes, byte entropyBytes, string &description ) : byte[]

Calls DPAPI CryptUnprotectData to decrypt ciphertext bytes.

When decrypting data, it is not necessary to specify which type of encryption key to use: user-specific or machine-specific; DPAPI will figure it out by looking at the signature of encrypted data.

Decrypt ( string cipherText ) : string

Calls DPAPI CryptUnprotectData to decrypt ciphertext bytes. This function does not use additional entropy and does not return data description.

When decrypting data, it is not necessary to specify which type of encryption key to use: user-specific or machine-specific; DPAPI will figure it out by looking at the signature of encrypted data.

Decrypt ( string cipherText, string &description ) : string

Calls DPAPI CryptUnprotectData to decrypt ciphertext bytes. This function does not use additional entropy.

When decrypting data, it is not necessary to specify which type of encryption key to use: user-specific or machine-specific; DPAPI will figure it out by looking at the signature of encrypted data.

Decrypt ( string cipherText, string entropy, string &description ) : string

Calls DPAPI CryptUnprotectData to decrypt ciphertext bytes.

When decrypting data, it is not necessary to specify which type of encryption key to use: user-specific or machine-specific; DPAPI will figure it out by looking at the signature of encrypted data.

Encrypt ( KeyType keyType, byte plainTextBytes, byte entropyBytes, string description ) : byte[]

Calls DPAPI CryptProtectData function to encrypt an array of plaintext bytes.

Encrypt ( KeyType keyType, string plainText ) : string

Calls DPAPI CryptProtectData function to encrypt a plaintext string value. This function does not specify data description and additional entropy.

Encrypt ( KeyType keyType, string plainText, string entropy ) : string

Calls DPAPI CryptProtectData function to encrypt a plaintext string value. This function does not specify data description.

Encrypt ( KeyType keyType, string plainText, string entropy, string description ) : string

Calls DPAPI CryptProtectData function to encrypt a plaintext string value.

Encrypt ( string plainText ) : string

Calls DPAPI CryptProtectData function to encrypt a plaintext string value with a user-specific key. This function does not specify data description and additional entropy.

Private Methods

Method Description
CryptProtectData ( DATA_BLOB &pPlainText, string szDescription, DATA_BLOB &pEntropy, IntPtr pReserved, CRYPTPROTECT_PROMPTSTRUCT &pPrompt, int dwFlags, DATA_BLOB &pCipherText ) : bool
CryptUnprotectData ( DATA_BLOB &pCipherText, string &pszDescription, DATA_BLOB &pEntropy, IntPtr pReserved, CRYPTPROTECT_PROMPTSTRUCT &pPrompt, int dwFlags, DATA_BLOB &pPlainText ) : bool
InitBLOB ( byte data, DATA_BLOB &blob ) : void

Initializes a BLOB structure from a byte array.

InitPrompt ( CRYPTPROTECT_PROMPTSTRUCT &ps ) : void

Initializes empty prompt structure.

Method Details

Decrypt() public static method

Calls DPAPI CryptUnprotectData to decrypt ciphertext bytes.
When decrypting data, it is not necessary to specify which type of encryption key to use: user-specific or machine-specific; DPAPI will figure it out by looking at the signature of encrypted data.
public static Decrypt ( byte cipherTextBytes, byte entropyBytes, string &description ) : byte[]
cipherTextBytes byte /// Encrypted data. ///
entropyBytes byte /// Optional entropy, which is required if it was specified during /// encryption. ///
description string /// Returned description of data specified during encryption. ///
return byte[]

Decrypt() public static method

Calls DPAPI CryptUnprotectData to decrypt ciphertext bytes. This function does not use additional entropy and does not return data description.
When decrypting data, it is not necessary to specify which type of encryption key to use: user-specific or machine-specific; DPAPI will figure it out by looking at the signature of encrypted data.
public static Decrypt ( string cipherText ) : string
cipherText string /// Encrypted data formatted as a base64-encoded string. ///
return string

Decrypt() public static method

Calls DPAPI CryptUnprotectData to decrypt ciphertext bytes. This function does not use additional entropy.
When decrypting data, it is not necessary to specify which type of encryption key to use: user-specific or machine-specific; DPAPI will figure it out by looking at the signature of encrypted data.
public static Decrypt ( string cipherText, string &description ) : string
cipherText string /// Encrypted data formatted as a base64-encoded string. ///
description string /// Returned description of data specified during encryption. ///
return string

Decrypt() public static method

Calls DPAPI CryptUnprotectData to decrypt ciphertext bytes.
When decrypting data, it is not necessary to specify which type of encryption key to use: user-specific or machine-specific; DPAPI will figure it out by looking at the signature of encrypted data.
public static Decrypt ( string cipherText, string entropy, string &description ) : string
cipherText string /// Encrypted data formatted as a base64-encoded string. ///
entropy string /// Optional entropy, which is required if it was specified during /// encryption. ///
description string /// Returned description of data specified during encryption. ///
return string

Encrypt() public static method

Calls DPAPI CryptProtectData function to encrypt an array of plaintext bytes.
public static Encrypt ( KeyType keyType, byte plainTextBytes, byte entropyBytes, string description ) : byte[]
keyType KeyType /// Defines type of encryption key to use. When user key is /// specified, any application running under the same user account /// as the one making this call, will be able to decrypt data. /// Machine key will allow any application running on the same /// computer where data were encrypted to perform decryption. /// Note: If optional entropy is specifed, it will be required /// for decryption. ///
plainTextBytes byte /// Plaintext data to be encrypted. ///
entropyBytes byte /// Optional entropy which - if specified - will be required to /// perform decryption. ///
description string /// Optional description of data to be encrypted. If this value is /// specified, it will be stored along with encrypted data and /// returned as a separate value during decryption. ///
return byte[]

Encrypt() public static method

Calls DPAPI CryptProtectData function to encrypt a plaintext string value. This function does not specify data description and additional entropy.
public static Encrypt ( KeyType keyType, string plainText ) : string
keyType KeyType /// Defines type of encryption key to use. When user key is /// specified, any application running under the same user account /// as the one making this call, will be able to decrypt data. /// Machine key will allow any application running on the same /// computer where data were encrypted to perform decryption. /// Note: If optional entropy is specifed, it will be required /// for decryption. ///
plainText string /// Plaintext data to be encrypted. ///
return string

Encrypt() public static method

Calls DPAPI CryptProtectData function to encrypt a plaintext string value. This function does not specify data description.
public static Encrypt ( KeyType keyType, string plainText, string entropy ) : string
keyType KeyType /// Defines type of encryption key to use. When user key is /// specified, any application running under the same user account /// as the one making this call, will be able to decrypt data. /// Machine key will allow any application running on the same /// computer where data were encrypted to perform decryption. /// Note: If optional entropy is specifed, it will be required /// for decryption. ///
plainText string /// Plaintext data to be encrypted. ///
entropy string /// Optional entropy which - if specified - will be required to /// perform decryption. ///
return string

Encrypt() public static method

Calls DPAPI CryptProtectData function to encrypt a plaintext string value.
public static Encrypt ( KeyType keyType, string plainText, string entropy, string description ) : string
keyType KeyType /// Defines type of encryption key to use. When user key is /// specified, any application running under the same user account /// as the one making this call, will be able to decrypt data. /// Machine key will allow any application running on the same /// computer where data were encrypted to perform decryption. /// Note: If optional entropy is specifed, it will be required /// for decryption. ///
plainText string /// Plaintext data to be encrypted. ///
entropy string /// Optional entropy which - if specified - will be required to /// perform decryption. ///
description string /// Optional description of data to be encrypted. If this value is /// specified, it will be stored along with encrypted data and /// returned as a separate value during decryption. ///
return string

Encrypt() public static method

Calls DPAPI CryptProtectData function to encrypt a plaintext string value with a user-specific key. This function does not specify data description and additional entropy.
public static Encrypt ( string plainText ) : string
plainText string /// Plaintext data to be encrypted. ///
return string