Stream Cipher

From Crypto++ Wiki
Jump to navigation Jump to search

A Stream Cipher is a symmetric key algorithm where plain text bytes are combined with a pseudorandom cipher byte stream or key stream.

Crypto++ includes the following stream ciphers:

Remarks

The same routine is used in either direction --encryption or decryption.

Examples

unsigned char* inOut;
unsigned int inOutSize;
unsigned char* key;
unsigned int keySize;

ARC4 rc4(key, keySize);
rc4.ProcessString(inOut, inOutSize);

To encrypt and decrypt with the same object, then you will have to rekey the object:

ARC4 rc4(key, keySize);

// Encrypt
rc4.ProcessString(inOut, inOutSize);

// Reset state
arc4.SetKey(key, keySize);

// Decrypt
rc4.ProcessString(inOut, inOutSize);