C# Class SagaLib.Encryption

Exibir arquivo Open project: Willyham/SagaRO2 Class Usage Examples

Public Properties

Property Type Description
StaticKey byte[]

Public Methods

Method Description
Crypt ( string msg, byte key, bool encrypt ) : string

Encrypt/Decrypt a given message with a given key.

Decrypt ( byte data, int offset, byte key ) : byte[]

Decrypt a byte array with a given key.

Encrypt ( byte data, int offset, byte key ) : byte[]

Encrypt a byte array with a given key.

GenerateDecExpKey ( byte key ) : byte[]

Generate the expanded key that will be used during decryption.

GenerateKey ( ) : byte[]

Generate a random 16 bytes AES key.

Private Methods

Method Description
Crypt ( byte data, int offset, byte orgkey, bool encrypt ) : byte[]
SwapBytes ( byte buffer, int len, int c ) : void

Method Details

Crypt() public static method

Encrypt/Decrypt a given message with a given key.
public static Crypt ( string msg, byte key, bool encrypt ) : string
msg string msg to encrypt/decrypt
key byte aes key to use
encrypt bool true: message will be encrypted. false: message will be decrypted.
return string

Decrypt() public static method

Decrypt a byte array with a given key.
public static Decrypt ( byte data, int offset, byte key ) : byte[]
data byte bytes to decrypt
offset int
key byte aes key to use
return byte[]

Encrypt() public static method

Encrypt a byte array with a given key.
public static Encrypt ( byte data, int offset, byte key ) : byte[]
data byte bytes to encrypt
offset int
key byte aes key to use
return byte[]

GenerateDecExpKey() public static method

Generate the expanded key that will be used during decryption.
public static GenerateDecExpKey ( byte key ) : byte[]
key byte AES key to expand.
return byte[]

GenerateKey() public static method

Generate a random 16 bytes AES key.
public static GenerateKey ( ) : byte[]
return byte[]

Property Details

StaticKey public_oe static_oe property

The static key is the key used to encrypt the first messages between client and server. In these messages a key exchange will take place which will be used for further communication.
public static byte[] StaticKey
return byte[]