00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef DEBUG
00019 #define DEBUG
00020 #endif
00021
00022 #include <ucommon-config.h>
00023 #include <ucommon/secure.h>
00024
00025 #include <stdio.h>
00026
00027 using namespace UCOMMON_NAMESPACE;
00028
00029 #define STR "this is a test of some text we wish to post"
00030
00031 int main(int argc, char **argv)
00032 {
00033 if(!secure::init())
00034 return 0;
00035
00036 skey_t mykey("aes256", "sha", "testing");
00037 cipher_t enc, dec;
00038 unsigned char ebuf[256], dbuf[256];
00039
00040 memset(dbuf, 0, sizeof(dbuf));
00041
00042 enc.set(&mykey, Cipher::ENCRYPT, ebuf);
00043 dec.set(&mykey, Cipher::DECRYPT, dbuf);
00044
00045 size_t total = enc.puts(STR);
00046
00047 assert(!eq(STR, (char *)ebuf, strlen(STR)));
00048
00049 assert(total == 48);
00050
00051 dec.put(ebuf, total);
00052 dec.flush();
00053 assert(eq((char *)dbuf, STR));
00054 return 0;
00055 }
00056