File:  [ELWIX - Embedded LightWeight unIX -] / libaitio / example / crypt.c
Revision 1.3: download - view: text, annotated - select for diffs - revision graph
Wed Jun 26 22:48:53 2013 UTC (10 years, 11 months ago) by misho
Branches: MAIN
CVS tags: io7_4, io7_3, io7_2, io7_1, io7_0, io6_9, io6_8, io6_7, io6_6, io6_5, io6_4, io6_3, io6_2, io6_1, io6_0, io5_9, io5_8, io5_7, io5_6, io5_5, IO7_3, IO7_2, IO7_1, IO7_0, IO6_9, IO6_8, IO6_7, IO6_6, IO6_5, IO6_4, IO6_3, IO6_2, IO6_1, IO6_0, IO5_9, IO5_8, IO5_7, IO5_6, IO5_5, IO5_4, HEAD
version 5.4

    1: /* $Id: crypt.c,v 1.3 2013/06/26 22:48:53 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((u_char*) 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>