C# 클래스 AnotherAES, code

Based on https://msdn.microsoft.com/en-us/library/system.security.cryptography.rijndaelmanaged(v=vs.110).aspx Uses UTF8 Encoding http://security.stackexchange.com/a/90850
상속: IDisposable
파일 보기 프로젝트 열기: shendongnian/code 1 사용 예제들

공개 메소드들

메소드 설명
AnotherAES ( string key )

Initialize algo just with key Defaults for RijndaelManaged class: Block Size: 256 bits (32 bytes) Key Size: 128 bits (16 bytes) Padding Mode: PKCS7 Cipher Mode: CBC

AnotherAES ( string key, int blockSize, int keySize, PaddingMode, paddingMode, CipherMode, cipherMode )

Initialize algo with key, block size, key size, padding mode and cipher mode to be known.

Decrypt ( Array, cipherText, Array, IV ) : string

Based on https://msdn.microsoft.com/en-us/library/system.security.cryptography.rijndaelmanaged(v=vs.110).aspx

Dispose ( ) : void

Dispose RijndaelManaged object initialized in the constructor

Encrypt ( string plainText, Array, IV ) : byte[]

Based on https://msdn.microsoft.com/en-us/library/system.security.cryptography.rijndaelmanaged(v=vs.110).aspx Encrypt a string using RijndaelManaged encryptor.

GenerateEncryptionVector ( ) : byte[]

Generates a unique encryption vector using RijndaelManaged.GenerateIV() method

GetUniqueString ( int numBytes ) : string

Based on http://stackoverflow.com/a/1344255 Generate a unique string given number of bytes required. This string can be used as IV. IV byte size should be equal to cipher-block byte size. Allows seeing IV in plaintext so it can be passed along a url or some message.

StringToByteArray ( String hex ) : byte[]

Based on http://stackoverflow.com/a/311179/1541224 Converts a string to byte array. Useful when converting back hex string which was originally formed from bytes.

메소드 상세

AnotherAES() 공개 메소드

Initialize algo just with key Defaults for RijndaelManaged class: Block Size: 256 bits (32 bytes) Key Size: 128 bits (16 bytes) Padding Mode: PKCS7 Cipher Mode: CBC
public AnotherAES ( string key )
key string

AnotherAES() 공개 메소드

Initialize algo with key, block size, key size, padding mode and cipher mode to be known.
public AnotherAES ( string key, int blockSize, int keySize, PaddingMode, paddingMode, CipherMode, cipherMode )
key string ASCII key to be used for encryption or decryption
blockSize int block size to use for AES algorithm. 128, 192 or 256 bits (default for incorrect size=256)
keySize int key length to use for AES algorithm. 128, 192, or 256 bits (default for incorrect size=128)
paddingMode PaddingMode,
cipherMode CipherMode,

Decrypt() 공개 메소드

Based on https://msdn.microsoft.com/en-us/library/system.security.cryptography.rijndaelmanaged(v=vs.110).aspx
public Decrypt ( Array, cipherText, Array, IV ) : string
cipherText Array, bytes to be decrypted back to plaintext
IV Array, initialization vector used to encrypt the bytes
리턴 string

Dispose() 공개 메소드

Dispose RijndaelManaged object initialized in the constructor
public Dispose ( ) : void
리턴 void

Encrypt() 공개 메소드

Based on https://msdn.microsoft.com/en-us/library/system.security.cryptography.rijndaelmanaged(v=vs.110).aspx Encrypt a string using RijndaelManaged encryptor.
public Encrypt ( string plainText, Array, IV ) : byte[]
plainText string string to be encrypted
IV Array, initialization vector to be used by crypto algorithm
리턴 byte[]

GenerateEncryptionVector() 공개 메소드

Generates a unique encryption vector using RijndaelManaged.GenerateIV() method
public GenerateEncryptionVector ( ) : byte[]
리턴 byte[]

GetUniqueString() 공개 정적인 메소드

Based on http://stackoverflow.com/a/1344255 Generate a unique string given number of bytes required. This string can be used as IV. IV byte size should be equal to cipher-block byte size. Allows seeing IV in plaintext so it can be passed along a url or some message.
public static GetUniqueString ( int numBytes ) : string
numBytes int
리턴 string

StringToByteArray() 공개 정적인 메소드

Based on http://stackoverflow.com/a/311179/1541224 Converts a string to byte array. Useful when converting back hex string which was originally formed from bytes.
public static StringToByteArray ( String hex ) : byte[]
hex String
리턴 byte[]