Skip to content

Instantly share code, notes, and snippets.

@gustavonovaes
Created July 15, 2016 11:40
Show Gist options
  • Save gustavonovaes/0c4cc4c573d46ac518e0a73b1c61bd27 to your computer and use it in GitHub Desktop.
Save gustavonovaes/0c4cc4c573d46ac518e0a73b1c61bd27 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
void encrypt(char *str_in, char *str_out, int base)
{
for (size_t i = 0; str_in[i] != 0; i++) {
sprintf(str_out + i * 2, "%02x", str_in[i] ^ base);
}
}
void decrypt(char *str_in, char *str_out, int base)
{
char buffer[3];
for (size_t i = 0; str_in[i] != 0; i += 2) {
strncpy(buffer, str_in + i, 2);
sprintf(str_out + strlen(str_out),"%c", strtol(buffer, NULL, 16) ^ base);
}
}
int main(int argc, char ** argv) {
//
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment