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);
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.
A generic data ciphering class.
size_t puts(const char *string)
This essentially encrypts a single string and pads with NULL bytes as needed.
size_t flush(void)
Push a final cipher block.
size_t put(const uint8_t *data, size_t size)
Process cipher data.
Cipher key formed by hash algorithm.