Odd Encoder output after disabling padding?

10 views
Skip to first unread message

Jeffrey Walton

unread,
Jan 16, 2015, 7:17:21 PM1/16/15
to cryptop...@googlegroups.com
I'm trying to turn off padding on a Base64 encoder. Essentially, the program tries to Base64 encode 128 bytes of data, but its producing this output:

$ ./cryptopp-test.exe
/+7dzLuqmYh3ZlVEMyIRAP/u3cy7qpmId2ZVRDMi
EQD/7t3Mu6qZiHdmVUQzIhEA/+7dzLuqmYh3ZlVE
MyIRAP/u3cy7qpmId2ZVRDMiEQD/7t3Mu6qZiHdm
VUQzIhEA/+7dzLuqmYh3ZlVEMyIRAP/u3cy7qpmI
d2ZVRDMiEQD/7t3Mu6qZiHdmVUQzIhEA/+7dzLuq
mYh3ZlVEMyIRAP/u3cy7qpmId2ZVRDMiEQD/7t3M
u6qZiHdmVUQzIhEA/+7dzLuqmYh3ZlVEMyIRAP/u
3cy7qpmId2ZVRDMiEQD/7t3Mu6qZiHdmVUQzIhEA
/+7dzLuqmYh3ZlVEMyIRAA


$

The whitespace is present in the output, so it was shown above.

Any ideas on what's going on?

----------

byte raw[] = { 0xFF, 0xEE, 0xDD, 0xCC, 0xBB, 0xAA, 0x99, 0x88,
    0x77, 0x66, 0x55, 0x44, 0x33, 0x22, 0x11, 0x00,
    0xFF, 0xEE, 0xDD, 0xCC, 0xBB, 0xAA, 0x99, 0x88,
    0xFF, 0xEE, 0xDD, 0xCC, 0xBB, 0xAA, 0x99, 0x88,
    0x77, 0x66, 0x55, 0x44, 0x33, 0x22, 0x11, 0x00,
    0xFF, 0xEE, 0xDD, 0xCC, 0xBB, 0xAA, 0x99, 0x88,
    0x77, 0x66, 0x55, 0x44, 0x33, 0x22, 0x11, 0x00,
    0xFF, 0xEE, 0xDD, 0xCC, 0xBB, 0xAA, 0x99, 0x88,
    0x77, 0x66, 0x55, 0x44, 0x33, 0x22, 0x11, 0x00,
    0xFF, 0xEE, 0xDD, 0xCC, 0xBB, 0xAA, 0x99, 0x88,
    0x77, 0x66, 0x55, 0x44, 0x33, 0x22, 0x11, 0x00,
    0xFF, 0xEE, 0xDD, 0xCC, 0xBB, 0xAA, 0x99, 0x88,
    0x77, 0x66, 0x55, 0x44, 0x33, 0x22, 0x11, 0x00,
    0xFF, 0xEE, 0xDD, 0xCC, 0xBB, 0xAA, 0x99, 0x88,
    0x77, 0x66, 0x55, 0x44, 0x33, 0x22, 0x11, 0x00,
};

string encoded, hexed;
Base64Encoder encoder;

AlgorithmParameters params = MakeParameters
                                (Pad(), false)
                                (MaxLineLength(), 40);
encoder.Initialize(params);

encoder.Attach(new StringSink(encoded));

encoder.Put(raw, sizeof(raw));
encoder.MessageEnd();

cout << encoded << endl;

StringSource ss(encoded, new Base64Decoder( new HexEncoder(new StringSink(hexed))));

cout << hexed << endl;
Reply all
Reply to author
Forward
Message has been deleted
0 new messages