C# 클래스 Zicore.Encryption.RijndaelSimple

This class uses a symmetric key algorithm (Rijndael/AES) to encrypt and decrypt data. As long as encryption and decryption routines use the same parameters to generate the keys, the keys are guaranteed to be the same. The class uses static functions with duplicate code to make it easier to demonstrate encryption and decryption logic. In a real-life application, this may not be the most efficient way of handling encryption, so - as soon as you feel comfortable with it - you may want to redesign this class.
파일 보기 프로젝트 열기: Zicore/TradingPostNotifier

공개 메소드들

메소드 설명
Decrypt ( this cipherText, string passPhrase, string saltValue, string hashAlgorithm, int passwordIterations, string initVector, int keySize ) : string

Decrypts specified ciphertext using Rijndael symmetric key algorithm.

Most of the logic in this function is similar to the Encrypt logic. In order for decryption to work, all parameters of this function - except cipherText value - must match the corresponding parameters of the Encrypt function which was called to generate the ciphertext.

DecryptFile ( byte cipherFile, string passPhrase, string saltValue, string hashAlgorithm, int passwordIterations, string initVector, int keySize ) : byte[]
Encrypt ( this plainText, string passPhrase, string saltValue, string hashAlgorithm, int passwordIterations, string initVector, int keySize ) : string

Encrypts specified plaintext using Rijndael symmetric key algorithm and returns a base64-encoded result.

EncryptFile ( byte file, string passPhrase, string saltValue, string hashAlgorithm, int passwordIterations, string initVector, int keySize ) : byte[]

메소드 상세

Decrypt() 공개 정적인 메소드

Decrypts specified ciphertext using Rijndael symmetric key algorithm.
Most of the logic in this function is similar to the Encrypt logic. In order for decryption to work, all parameters of this function - except cipherText value - must match the corresponding parameters of the Encrypt function which was called to generate the ciphertext.
public static Decrypt ( this cipherText, string passPhrase, string saltValue, string hashAlgorithm, int passwordIterations, string initVector, int keySize ) : string
cipherText this /// Base64-formatted ciphertext value. ///
passPhrase string /// Passphrase from which a pseudo-random password will be derived. The /// derived password will be used to generate the encryption key. /// Passphrase can be any string. In this example we assume that this /// passphrase is an ASCII string. ///
saltValue string /// Salt value used along with passphrase to generate password. Salt can /// be any string. In this example we assume that salt is an ASCII string. ///
hashAlgorithm string /// Hash algorithm used to generate password. Allowed values are: "MD5" and /// "SHA1". SHA1 hashes are a bit slower, but more secure than MD5 hashes. ///
passwordIterations int /// Number of iterations used to generate password. One or two iterations /// should be enough. ///
initVector string /// Initialization vector (or IV). This value is required to encrypt the /// first block of plaintext data. For RijndaelManaged class IV must be /// exactly 16 ASCII characters long. ///
keySize int /// Size of encryption key in bits. Allowed values are: 128, 192, and 256. /// Longer keys are more secure than shorter keys. ///
리턴 string

DecryptFile() 공개 정적인 메소드

public static DecryptFile ( byte cipherFile, string passPhrase, string saltValue, string hashAlgorithm, int passwordIterations, string initVector, int keySize ) : byte[]
cipherFile byte
passPhrase string
saltValue string
hashAlgorithm string
passwordIterations int
initVector string
keySize int
리턴 byte[]

Encrypt() 공개 정적인 메소드

Encrypts specified plaintext using Rijndael symmetric key algorithm and returns a base64-encoded result.
public static Encrypt ( this plainText, string passPhrase, string saltValue, string hashAlgorithm, int passwordIterations, string initVector, int keySize ) : string
plainText this /// Plaintext value to be encrypted. ///
passPhrase string /// Passphrase from which a pseudo-random password will be derived. The /// derived password will be used to generate the encryption key. /// Passphrase can be any string. In this example we assume that this /// passphrase is an ASCII string. ///
saltValue string /// Salt value used along with passphrase to generate password. Salt can /// be any string. In this example we assume that salt is an ASCII string. ///
hashAlgorithm string /// Hash algorithm used to generate password. Allowed values are: "MD5" and /// "SHA1". SHA1 hashes are a bit slower, but more secure than MD5 hashes. ///
passwordIterations int /// Number of iterations used to generate password. One or two iterations /// should be enough. ///
initVector string /// Initialization vector (or IV). This value is required to encrypt the /// first block of plaintext data. For RijndaelManaged class IV must be /// exactly 16 ASCII characters long. ///
keySize int /// Size of encryption key in bits. Allowed values are: 128, 192, and 256. /// Longer keys are more secure than shorter keys. ///
리턴 string

EncryptFile() 공개 정적인 메소드

public static EncryptFile ( byte file, string passPhrase, string saltValue, string hashAlgorithm, int passwordIterations, string initVector, int keySize ) : byte[]
file byte
passPhrase string
saltValue string
hashAlgorithm string
passwordIterations int
initVector string
keySize int
리턴 byte[]