You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
869 B
40 lines
869 B
#include <mcrypt.h>
|
|
#include <string.h>
|
|
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include <sys/types.h>
|
|
|
|
#include "token/cclass.h"
|
|
#include "token/crypt.h"
|
|
#include "base64.h"
|
|
|
|
|
|
int
|
|
main(int argc, char * argv[])
|
|
{
|
|
char data[] = "ein weiterer test";
|
|
char pass[] = "1234";
|
|
char * b64d = NULL;
|
|
char * encrypted = NULL;
|
|
size_t length = strlen(data);
|
|
|
|
struct CRYPT * crypt = NULL;
|
|
|
|
crypt = new(CRYPT, MCRYPT_RIJNDAEL_256, MCRYPT_CFB);
|
|
encrypted = crypt_encrypt(crypt, data, pass, &length);
|
|
delete(crypt);
|
|
|
|
b64d = calloc(BASE64_LENGTH(length), sizeof(char));
|
|
base64_encode(encrypted, length, b64d, BASE64_LENGTH(length));
|
|
free(encrypted);
|
|
|
|
b64d = realloc(b64d, BASE64_LENGTH(length) + 1);
|
|
b64d[BASE64_LENGTH(length)] = '\0';
|
|
|
|
printf("%s\n", b64d);
|
|
free(b64d);
|
|
|
|
return 0;
|
|
}
|
|
|
|
// vim: set et ts=4 sw=4:
|