netcrypt.c 317 B

123456789101112131415161718
  1. #include <u.h>
  2. #include <libc.h>
  3. #include <auth.h>
  4. int
  5. netcrypt(void *key, void *chal)
  6. {
  7. uchar buf[8], *p;
  8. strncpy((char*)buf, chal, 7);
  9. buf[7] = '\0';
  10. for(p = buf; *p && *p != '\n'; p++)
  11. ;
  12. *p = '\0';
  13. encrypt(key, buf, 8);
  14. sprint(chal, "%.2ux%.2ux%.2ux%.2ux", buf[0], buf[1], buf[2], buf[3]);
  15. return 1;
  16. }