File:  [ELWIX - Embedded LightWeight unIX -] / libaitio / example / crypt.c
Revision 1.2: download - view: text, annotated - select for diffs - revision graph
Tue Apr 19 20:00:30 2011 UTC (13 years, 2 months ago) by misho
Branches: MAIN
CVS tags: io5_4, io5_3, io5_2, io5_1, io5_0, io4_1, io4_0, io3_9, io3_8, io3_7, io3_6, io3_5, io3_4, io3_3, io3_2, io3_1, io2_8, io2_7, io2_6, io2_5, io2_4, io2_3, io2_2, io2_1, io2_0, io1_9, io1_8, io1_7, IO5_3, IO5_2, IO5_1, IO5_0, IO4_1, IO4_0, IO3_9, IO3_8, IO3_7, IO3_6, IO3_5, IO3_4, IO3_3, IO3_2, IO3_1, IO3_0, IO2_7, IO2_6, IO2_5, IO2_4, IO2_3, IO2_2, IO2_1, IO2_0, IO1_9, IO1_8, IO1_7, IO1_6, HEAD
release 1.6

    1: /* $Id: crypt.c,v 1.2 2011/04/19 20:00:30 misho Exp $ */
    2: 
    3: #include <stdio.h>
    4: #include <unistd.h>
    5: #include <string.h>
    6: #include <aitio.h>
    7: 
    8: int main(int argc, char **argv)
    9: {
   10: 	char ch, *str, mode = -1;
   11: 	int len;
   12: 
   13: 	while ((ch = getopt(argc, argv, "de")) != -1)
   14: 		switch (ch) {
   15: 			case 'e':
   16: 				mode = 1;
   17: 				break;
   18: 			case 'd':
   19: 				mode = 0;
   20: 				break;
   21: 			default:
   22: 				printf("Not enough parameters ... blowfishche [-e|-d] <string>\n");
   23: 				return 1;
   24: 		}
   25: 	argc -= optind;
   26: 	argv += optind;
   27: 	if (argc < 1 || -1 == mode) {
   28: 		printf("Not enough parameters ... blowfishche [-e|-d] <string>\n");
   29: 		return 1;
   30: 	}
   31: 
   32: 	len = io_Blowfish(argv[0], strlen(argv[0]), (unsigned char**) &str, NULL, NULL, mode);
   33: 
   34: 	if (len && str) {
   35: 		printf("Action(%scrypt)%d: %s\n", !mode ? "de" : "en", len, str);
   36: 		free(str);
   37: 	} else
   38: 		printf("Invalid action!!!\n");
   39: 
   40: 	return 0;
   41: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>