File:  [ELWIX - Embedded LightWeight unIX -] / libaitio / example / crypt.c
Revision 1.2.56.1: download - view: text, annotated - select for diffs - revision graph
Tue Jun 25 09:22:10 2013 UTC (11 years ago) by misho
Branches: io5_4
Diff to: branchpoint 1.2: preferred, colored
fix issues reported from clang

/* $Id: crypt.c,v 1.2.56.1 2013/06/25 09:22:10 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((u_char*) 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>