CRijndael only encrpyting first 32 bytes of longer string

332 views Asked by At

I'm using CRijndael ( http://www.codeproject.com/Articles/1380/A-C-Implementation-of-the-Rijndael-Encryption-Decr ) for encryption using a null based iv (I know that's an issue but for certain reasons I'm stuck with having to use that).

For strings that are longer (or contain a few ampersands) I'm only ever getting the first 32 bytes encrypted. Shorter strings are encrypted without any issues. Code is below, any ideas?

    char dataIn[] = "LONG STRING HERE";
    string preInput = dataIn;


    CRijndael aRijndael;
    aRijndael.MakeKey("32-BIT-KEY-HERE", CRijndael::sm_chain0, 32, 16);



    while (preInput.length() % 16 != 0) {
        preInput += '\0';
    }
    const char *encInput = preInput.c_str();
    char szReq[1000];
    aRijndael.Encrypt(preInput.c_str(), szReq, preInput.size(), CRijndael::CBC);

    const std::string preBase64 = szReq;
    std::string encoded = base64_encode(reinterpret_cast<const unsigned char*>(preBase64.c_str()), preBase64.length());
0

There are 0 answers