Example of cipher code.
Example of cipher code.
#ifndef DEBUG
#define DEBUG
#endif
#include <ucommon-config.h>
#include <stdio.h>
#define STR "this is a test of some text we wish to post"
int main(int argc, char **argv)
{
if(!secure::init())
return 0;
skey_t mykey(
"aes256",
"sha",
"testing");
uint8_t ebuf[256], dbuf[256];
memset(dbuf, 0, sizeof(dbuf));
enc.set(&mykey, Cipher::ENCRYPT, ebuf);
dec.set(&mykey, Cipher::DECRYPT, dbuf);
size_t total = enc.puts(STR);
assert(!eq(STR, (char *)ebuf, strlen(STR)));
assert(total == 48);
dec.put(ebuf, total);
dec.flush();
assert(eq((char *)dbuf, STR));
return 0;
}
This library holds basic cryptographic functions and secure socket support for use with GNU uCommon C...
Common namespace for all ucommon objects.
Cipher cipher_t
Convenience type for generic ciphers.
Cipher::Key skey_t
Convenience type for generic cipher key.