C# Class FlexiWebSDK.Crypto.BlowfishCrypt

Inheritance: ICryptProvider
Afficher le fichier Open project: FlexiDB/PublicCSharpLib

Méthodes publiques

Méthode Description
BlowfishCrypt ( ) : System
BlowfishCrypt ( byte cipherKey ) : System

Constructor for byte key

BlowfishCrypt ( string hexKey ) : System

Constructor for hex key

Crypt_CTR ( byte text, int numThreads ) : byte[]
Decrypt ( string ct ) : string
Decrypt_CBC ( byte ct ) : byte[]

Decrypts a byte array in CBC mode. IV must be created and saved manually.

Decrypt_CBC ( string ct ) : string

Decrypts a string in CBC mode

Decrypt_CTR ( string ct ) : string

Decrypt a string (CTR)

Decrypt_ECB ( byte ct ) : byte[]

Decrypts a byte array (ECB)

Decrypt_ECB ( string ct ) : string

Decrypts a string (ECB)

Encrypt ( string pt ) : string
Encrypt_CBC ( byte pt ) : byte[]

Encrypts a byte array in CBC mode. IV must be created and saved manually.

Encrypt_CBC ( string pt ) : string

Encrypts a string in CBC mode

Encrypt_CTR ( string pt ) : string

Encrypts a string (CTR)

Encrypt_ECB ( byte pt ) : byte[]

Encrypts a byte array in ECB mode

Encrypt_ECB ( string pt ) : string

Encrypt a string in ECB mode

SetKey ( byte key ) : void
SetKey ( string key ) : void
SetRandomIV ( ) : byte[]

Creates and sets a random initialization vector.

Private Methods

Méthode Description
BlockDecrypt ( byte &block ) : void

Decrypts a 64 bit block

BlockEncrypt ( byte &block ) : void

Encrypts a 64 bit block

ByteToHex ( byte bytes ) : string
Crypt_CBC ( byte text, bool decrypt ) : byte[]

Encrypts or decrypts data in CBC mode

Crypt_ECB ( byte text, bool decrypt ) : byte[]

Encrypts or decrypts data in ECB mode

GetBlock ( byte &block ) : void

Converts the two uint values into a 64 bit block

GetHex ( char x ) : byte
HexToByte ( string hex ) : byte[]
SetBlock ( byte block ) : void

Splits the block into the two uint values

SetupKey ( byte cipherKey ) : void

Sets up the S-blocks and the key

SetupP ( ) : uint[]
SetupS0 ( ) : uint[]
SetupS1 ( ) : uint[]
SetupS2 ( ) : uint[]
SetupS3 ( ) : uint[]
XorBlock ( byte &block, byte iv ) : void

XoR encrypts two 8 bit blocks

decipher ( ) : void

Runs the blowfish algorithm in reverse (standard 16 rounds)

encipher ( ) : void

Runs the blowfish algorithm (standard 16 rounds)

round ( uint a, uint b, uint n ) : uint

one round of the blowfish algorithm

wordByte0 ( uint w ) : byte
wordByte1 ( uint w ) : byte
wordByte2 ( uint w ) : byte
wordByte3 ( uint w ) : byte

Method Details

BlowfishCrypt() public méthode

public BlowfishCrypt ( ) : System
Résultat System

BlowfishCrypt() public méthode

Constructor for byte key
public BlowfishCrypt ( byte cipherKey ) : System
cipherKey byte Cipher key as a byte array
Résultat System

BlowfishCrypt() public méthode

Constructor for hex key
public BlowfishCrypt ( string hexKey ) : System
hexKey string Cipher key as a hex string
Résultat System

Crypt_CTR() public méthode

public Crypt_CTR ( byte text, int numThreads ) : byte[]
text byte
numThreads int
Résultat byte[]

Decrypt() public méthode

public Decrypt ( string ct ) : string
ct string
Résultat string

Decrypt_CBC() public méthode

Decrypts a byte array in CBC mode. IV must be created and saved manually.
public Decrypt_CBC ( byte ct ) : byte[]
ct byte Ciphertext data to decrypt
Résultat byte[]

Decrypt_CBC() public méthode

Decrypts a string in CBC mode
public Decrypt_CBC ( string ct ) : string
ct string Ciphertext with IV appended to front
Résultat string

Decrypt_CTR() public méthode

Decrypt a string (CTR)
public Decrypt_CTR ( string ct ) : string
ct string The ciphertext to decrypt
Résultat string

Decrypt_ECB() public méthode

Decrypts a byte array (ECB)
public Decrypt_ECB ( byte ct ) : byte[]
ct byte Ciphertext byte array
Résultat byte[]

Decrypt_ECB() public méthode

Decrypts a string (ECB)
public Decrypt_ECB ( string ct ) : string
ct string hHex string of the ciphertext
Résultat string

Encrypt() public méthode

public Encrypt ( string pt ) : string
pt string
Résultat string

Encrypt_CBC() public méthode

Encrypts a byte array in CBC mode. IV must be created and saved manually.
public Encrypt_CBC ( byte pt ) : byte[]
pt byte Plaintext data to encrypt
Résultat byte[]

Encrypt_CBC() public méthode

Encrypts a string in CBC mode
public Encrypt_CBC ( string pt ) : string
pt string Plaintext data to encrypt
Résultat string

Encrypt_CTR() public méthode

Encrypts a string (CTR)
public Encrypt_CTR ( string pt ) : string
pt string The plaintext to encrypt
Résultat string

Encrypt_ECB() public méthode

Encrypts a byte array in ECB mode
public Encrypt_ECB ( byte pt ) : byte[]
pt byte Plaintext data
Résultat byte[]

Encrypt_ECB() public méthode

Encrypt a string in ECB mode
public Encrypt_ECB ( string pt ) : string
pt string Plaintext to encrypt as ascii string
Résultat string

SetKey() public méthode

public SetKey ( byte key ) : void
key byte
Résultat void

SetKey() public méthode

public SetKey ( string key ) : void
key string
Résultat void

SetRandomIV() public méthode

Creates and sets a random initialization vector.
public SetRandomIV ( ) : byte[]
Résultat byte[]