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)
{
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;
}
T * init(T *memory)
Template function to initialize memory by invoking default constructor.
This library holds basic cryptographic functions and secure socket support for use with GNU uCommon C...
Common namespace for all ucommon objects.
bool eq(const struct sockaddr *s1, const struct sockaddr *s2)
Compare two socket addresses to see if equal.
Cipher cipher_t
Convenience type for generic ciphers.
Cipher::Key skey_t
Convenience type for generic cipher key.