00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include <netcomm/worldinfo/encrypt.h>
00027 #include <netcomm/worldinfo/decrypt.h>
00028
00029 #include <cstdlib>
00030 #include <cstddef>
00031 #include <cstring>
00032 #include <iostream>
00033
00034 using namespace std;
00035 using namespace fawkes;
00036
00037 #define MAXLENGTH 1200
00038
00039 int
00040 main(int argc, char **argv)
00041 {
00042
00043
00044 WorldInfoMessageEncryptor *e = new WorldInfoMessageEncryptor((const unsigned char *)"QAKEY",
00045 (const unsigned char *)"QAIV123456");
00046 WorldInfoMessageDecryptor *d = new WorldInfoMessageDecryptor((const unsigned char *)"QAKEY",
00047 (const unsigned char *)"QAIV123456");
00048
00049
00050 char *input = (char *)malloc(MAXLENGTH);
00051 char *output = (char *)malloc(MAXLENGTH);
00052 e->set_plain_buffer(input, MAXLENGTH);
00053 char *crypted = (char *)malloc(e->recommended_crypt_buffer_size());
00054 e->set_crypt_buffer(crypted, e->recommended_crypt_buffer_size());
00055
00056 strncpy(input, "Test String 12345", MAXLENGTH);
00057 printf("Plain text: %s\n", input);
00058
00059 e->set_plain_buffer(input, strlen(input));
00060 long unsigned int bytes = e->encrypt();
00061
00062 printf("Encrypted to %lu bytes ", bytes);
00063
00064
00065
00066 printf("\n");
00067
00068 memset(output, 0, MAXLENGTH);
00069 d->set_crypt_buffer(crypted, bytes);
00070 d->set_plain_buffer(output, MAXLENGTH);
00071 bytes = d->decrypt();
00072
00073 printf("Decrypted to %lu bytes: %s\n", bytes, output);
00074
00075 free(input);
00076 free(output);
00077
00078 delete e;
00079 delete d;
00080
00081 return 0;
00082 }
00083
00084