26 #include <netcomm/worldinfo/decrypt.h>
27 #include <netcomm/worldinfo/encrypt.h>
37 #define MAXLENGTH 1200
40 main(
int argc,
char **argv)
44 WorldInfoMessageEncryptor *e =
new WorldInfoMessageEncryptor((
const unsigned char *)
"QAKEY",
45 (
const unsigned char *)
"QAIV123456");
46 WorldInfoMessageDecryptor *d =
new WorldInfoMessageDecryptor((
const unsigned char *)
"QAKEY",
47 (
const unsigned char *)
"QAIV123456");
49 char *input = (
char *)malloc(MAXLENGTH);
50 char *output = (
char *)malloc(MAXLENGTH);
51 e->set_plain_buffer(input, MAXLENGTH);
52 char *crypted = (
char *)malloc(e->recommended_crypt_buffer_size());
53 e->set_crypt_buffer(crypted, e->recommended_crypt_buffer_size());
55 strncpy(input,
"Test String 12345", MAXLENGTH);
56 printf(
"Plain text: %s\n", input);
58 e->set_plain_buffer(input, strlen(input));
59 long unsigned int bytes = e->encrypt();
61 printf(
"Encrypted to %lu bytes ", bytes);
67 memset(output, 0, MAXLENGTH);
68 d->set_crypt_buffer(crypted, bytes);
69 d->set_plain_buffer(output, MAXLENGTH);
72 printf(
"Decrypted to %lu bytes: %s\n", bytes, output);