c++encryptionaestwofish

AES Library or code for C++


I'm supposed to overload the class below twice. Once I'm supposed to implement it with AES (Rijndael) and once with Twofish. However, I can't seem to find a simple implementation that allows to encrypt only a single block. The implementations I found come with included CBC and Padding. Any hint?

#ifndef CRYPTER_H
#define CRYPTER_H

#include <valarray>

class Crypter {
public:
    Crypter();
    virtual ~Crypter();

    //Encrypts a single block of 16 byte.
    virtual std::valarray<unsigned char> encrypt(std::valarray<unsigned char> plaintext,
            std::valarray<unsigned char> passphrase) = 0;

    //Decrypts a single block of 16 byte.
    virtual std::valarray<unsigned char> decrypt(std::valarray<unsigned char> cyphertext,
            std::valarray<unsigned char> passphrase) = 0;     
};
#endif  /* CRYPTER_H */

Solution

  • Openssl is the best crypto library for C/C++ and I think it's definitely worth to give it a look.

    You can always break data yourself into blocks and encrypt/decrypt with library functions.