Created
December 13, 2016 09:30
-
-
Save quydm/cd2df1ba7213a7f598529e59f5ee843c to your computer and use it in GitHub Desktop.
XXTEA sample for C
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <string.h> | |
#include "base64.h" | |
#include "xxtea.h" | |
int main(int argc, const char * argv[]) { | |
const char *key = "123456"; | |
const char *str = "Lorem ipsum dolor sit amet, consectetur adipiscing elit"; | |
size_t len; | |
unsigned char *encrypt_data = xxtea_encrypt(str, strlen(str), key, &len); | |
char *base64_data = base64_encode(encrypt_data, len); | |
printf("encrypt_data: %s\n", base64_data); | |
unsigned char *decode_data = base64_decode(base64_data, &len); | |
char *decrypt_data = xxtea_decrypt(decode_data, len, key, &len); | |
printf("decrypt_data: %s\n", decrypt_data); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment