10 char data
[] = "This is a test.";
11 char expect
[] = "\x22\x30\x7e\x2f\x42\x28\x44\x01\xda\xdf\x5a\x81\xd7\xe5\x7c\xd0";
12 char key
[] = "testkey";
13 unsigned long et
[] = {0x11223344};
15 printf("%d: 0x11 == %d and 0x44 == %d\n", ((unsigned char *)et
)[0],
18 // bf = new CipherBlockChain(new BlowFish());
20 bf
->setKey((void *)key
, 7*8);
22 if (!bf
->readyToGo()) {
23 printf("Error: not ready to go!\n");
27 printf("About to encrypt...\n"); fflush(stdout
);
28 if (-1 == bf
->encrypt((void *)data
, 8)) {
29 printf("Error: encrypt failed!\n");
32 printf("About to encrypt part 2...\n"); fflush(stdout
);
33 bf
->encrypt((void *)(data
+8), 8);
35 printf("Encryption done. data[] is now: ");
36 for (int i
= 0; i
< 16; i
++) {
37 printf("0x%x ", data
[i
]&0xff);
38 if ((data
[i
]&0xff) != (expect
[i
]&0xff)) {
39 printf("Error. This byte failed the comparison. It should have been 0x%x.\n", expect
[i
]&0xff);
47 // bf = new CipherBlockChain(new BlowFish());
48 bf
->setKey((void *)key
, 7*8);
50 printf("About to decrypt...\n"); fflush(stdout
);
51 if (-1 == bf
->decrypt((void *)data
, 16)) {
52 printf("Error: decrypt failed!\n");
55 //bf->decrypt((void *)(data+8), 8);
57 printf("All done! Result... data[] = \"%s\"\n", data
);
58 if (strcmp(data
, "This is a test.")) {
59 printf("ERROR. Decryption failed.\n");