Shows how to use field-encryption API to encrypt JSON values.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef _WIN32
#define PRIx64 "I64x"
#else
#include <inttypes.h>
#endif
#include "openssl_symmetric_provider.h"
{
fprintf(stderr,
"%s. Received code 0x%X (%s)\n", msg, err,
lcb_strerror(instance, err));
exit(EXIT_FAILURE);
}
{
fprintf(stderr,
"CAS: 0x%" PRIx64
"\n", rb->
cas);
} else {
}
}
static void store_encrypted(
lcb_t instance,
const char *key,
const char *val)
{
printf("KEY: %s\n", key);
printf("PLAIN: %s\n", val);
field.
alg =
"AES-256-HMAC-SHA256";
die(instance, "Couldn't encrypt field 'message'", err);
}
if (ecmd.
out[ecmd.
nout - 1] ==
'\n') {
}
printf(
"CIPHER: %s\n", ecmd.
out);
die(instance, "Couldn't schedule storage operation", err);
}
}
int main(int argc, char *argv[])
{
{
if (argc < 2) {
fprintf(stderr, "Usage: %s couchbase://host/bucket [ password [ username ] ]\n", argv[0]);
exit(EXIT_FAILURE);
}
if (argc > 2) {
}
if (argc > 3) {
}
die(NULL, "Couldn't create couchbase handle", err);
}
die(instance, "Couldn't schedule connection", err);
}
die(instance, "Couldn't bootstrap from cluster", err);
}
}
store_encrypted(instance, "secret-1", "{\"message\":\"The old grey goose jumped over the wrickety gate.\"}");
printf("\n");
store_encrypted(instance, "secret-2", "{\"message\":10}");
printf("\n");
store_encrypted(instance, "secret-3", "{\"message\":\"10\"}");
printf("\n");
store_encrypted(instance, "secret-4", "{\"message\":[\"The\",\"Old\",\"Grey\",\"Goose\",\"Jumped\",\"over\",\"the\",\"wrickety\",\"gate\"]}");
printf("\n");
store_encrypted(instance, "secret-5", "{\"message\":{\"myValue\":\"The old grey goose jumped over the wrickety gate.\",\"myInt\":10}}");
return 0;
}