Skip to content

Instantly share code, notes, and snippets.

@rspencer01
Created January 20, 2018 15:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rspencer01/78edb444213045f14ae2b1cedcd340bb to your computer and use it in GitHub Desktop.
Save rspencer01/78edb444213045f14ae2b1cedcd340bb to your computer and use it in GitHub Desktop.
Encrypts a JSON with Cape
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include "src/Cape_c.h"
int main() {
cape_t cape;
cape_init(&cape, "THISISAKEY", 10, 210);
const char* message = "{\n'positions' :\n[0.449359147665,0.768063176032,0.15703541789,0.94458536882,0.21469166079,0.287691192213,0.881417496469,0.5292676022,0.762144864619]}";
unsigned char encrypted[220];
cape_encrypt(&cape, message, encrypted, strlen(message),13);
for (int i = 0;i<strlen(message)+1; ++i)
{
printf("0x%02x",encrypted[i]);
if (i<strlen(message)) printf(",");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment