#include <stdio.h> #include <stdlib.h> #include <string.h> #define ENCRYPT(a,b) (encrypt_decrypt (a, b)) #define DECRYPT(a,b) (encrypt_decrypt (a, b)) signed char * encrypt_decrypt (char *str, char *key) { char *crp_str, *addr; crp_str = addr = (char *) malloc (strlen (str)); if (crp_str == 0) return (char *)-1; for (; *str; str++, key++, crp_str++) *crp_str = *str ^ *key; *crp_str = '\0'; return addr; } int main (void) { char *str; str = ENCRYPT ("Hello World", "Im nice guy"); printf ("%s\n", DECRYPT (str, "Im nice guy")); return 0; }
Nenhum comentário:
Postar um comentário