--- libaitio/example/crypt.c 2011/03/16 17:05:46 1.1 +++ libaitio/example/crypt.c 2011/04/19 20:00:30 1.2 @@ -0,0 +1,41 @@ +/* $Id: crypt.c,v 1.2 2011/04/19 20:00:30 misho Exp $ */ + +#include +#include +#include +#include + +int main(int argc, char **argv) +{ + char ch, *str, mode = -1; + int len; + + while ((ch = getopt(argc, argv, "de")) != -1) + switch (ch) { + case 'e': + mode = 1; + break; + case 'd': + mode = 0; + break; + default: + printf("Not enough parameters ... blowfishche [-e|-d] \n"); + return 1; + } + argc -= optind; + argv += optind; + if (argc < 1 || -1 == mode) { + printf("Not enough parameters ... blowfishche [-e|-d] \n"); + return 1; + } + + len = io_Blowfish(argv[0], strlen(argv[0]), (unsigned char**) &str, NULL, NULL, mode); + + if (len && str) { + printf("Action(%scrypt)%d: %s\n", !mode ? "de" : "en", len, str); + free(str); + } else + printf("Invalid action!!!\n"); + + return 0; +}