Fawkes API
Fawkes Development Version
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
All
Classes
Namespaces
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Groups
Pages
qa_worldinfo_encryption.cpp
1
2
/***************************************************************************
3
* qa_worldinfo_encrypt.cpp - Fawkes QA WorldInfo encryption
4
*
5
* Created: Fri May 04 13:38:50 2007
6
* Copyright 2006-2007 Tim Niemueller [www.niemueller.de]
7
*
8
****************************************************************************/
9
10
/* This program is free software; you can redistribute it and/or modify
11
* it under the terms of the GNU General Public License as published by
12
* the Free Software Foundation; either version 2 of the License, or
13
* (at your option) any later version. A runtime exception applies to
14
* this software (see LICENSE.GPL_WRE file mentioned below for details).
15
*
16
* This program is distributed in the hope that it will be useful,
17
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
* GNU Library General Public License for more details.
20
*
21
* Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22
*/
23
24
/// @cond QA
25
26
#include <netcomm/worldinfo/encrypt.h>
27
#include <netcomm/worldinfo/decrypt.h>
28
29
#include <cstdlib>
30
#include <cstddef>
31
#include <cstring>
32
#include <iostream>
33
34
using namespace
std;
35
using namespace
fawkes;
36
37
#define MAXLENGTH 1200
38
39
int
40
main(
int
argc,
char
**argv)
41
{
42
// ArgumentParser *argp = new ArgumentParser(argc, argv, "rl");
43
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"
);
48
49
50
char
*input = (
char
*)malloc(MAXLENGTH);
51
char
*output = (
char
*)malloc(MAXLENGTH);
52
e->
set_plain_buffer
(input, MAXLENGTH);
53
char
*crypted = (
char
*)malloc(e->
recommended_crypt_buffer_size
());
54
e->
set_crypt_buffer
(crypted, e->
recommended_crypt_buffer_size
());
55
56
strncpy(input,
"Test String 12345"
, MAXLENGTH);
57
printf(
"Plain text: %s\n"
, input);
58
59
e->
set_plain_buffer
(input, strlen(input));
60
long
unsigned
int
bytes = e->
encrypt
();
61
62
printf(
"Encrypted to %lu bytes "
, bytes);
63
//for (size_t i = 0; i < bytes; i += 4) {
64
// printf("%x", crypted[i]);
65
//}
66
printf(
"\n"
);
67
68
memset(output, 0, MAXLENGTH);
69
d->
set_crypt_buffer
(crypted, bytes);
70
d->
set_plain_buffer
(output, MAXLENGTH);
71
bytes = d->
decrypt
();
72
73
printf(
"Decrypted to %lu bytes: %s\n"
, bytes, output);
74
75
free(input);
76
free(output);
77
78
delete
e;
79
delete
d;
80
//delete argp;
81
return
0;
82
}
83
84
/// @endcond
src
libs
netcomm
qa
qa_worldinfo_encryption.cpp
Generated by
1.8.3.1