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, 3 months ago) by misho
Branches: io1_6
added new test for crypto framework

/* $Id: crypt.c,v 1.1.2.1 2011/03/16 17:05:46 misho Exp $ */

#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <aitio.h>

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] <string>\n");
				return 1;
		}
	argc -= optind;
	argv += optind;
	if (argc < 1 || -1 == mode) {
		printf("Not enough parameters ... blowfishche [-e|-d] <string>\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;
}

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