File:  [ELWIX - Embedded LightWeight unIX -] / libaitio / example / crypt.c
Revision 1.1.2.1: download - view: text, annotated - select for diffs - revision graph
Wed Mar 16 17:05:46 2011 UTC (13 years, 4 months ago) by misho
Branches: io1_6
added new test for crypto framework

    1: /* $Id: crypt.c,v 1.1.2.1 2011/03/16 17:05:46 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>