Plan 9 from User Space's /usr/local/plan9/9pm/src/libc/port/netcrypt.c

#include <9pm/u.h>
#include <9pm/libc.h>
#include <9pm/auth.h>

int
netcrypt(void *key, void *chal)
{
	uchar buf[8], *p;

	strncpy((char*)buf, chal, 7);
	buf[7] = '\0';
	for(p = buf; *p && *p != '\n'; p++)
		;
	*p = '\0';
	encrypt(key, buf, 8);
	sprint(chal, "%.2ux%.2ux%.2ux%.2ux", buf[0], buf[1], buf[2], buf[3]);
	return 1;
}

Space Glenda

Copyright © 2005 Lucent Technologies, Russ Cox, MIT.
See license for details.