home *** CD-ROM | disk | FTP | other *** search
/ Boldly Go Collection / version40.iso / TS / 17A / DES_1991.ZIP / DESTEST.C < prev    next >
C/C++ Source or Header  |  1991-06-21  |  642b  |  42 lines

  1. #include <stdio.h>
  2. main()
  3. {
  4.     char key[8],work[8];
  5.     char ks[16][8];
  6.  
  7.     desinit(0);
  8.     printf("Ready\n");
  9.     get8(key);
  10.     printf("Setting key: "); put8(key); printf("\n");
  11.     setkey(ks,key);
  12.     printf("Key set\n");
  13.  
  14.     while(!feof(stdin)){
  15.         get8(work);
  16.         printf("Plain: "); put8(work); printf("\n");
  17.         endes(ks,work);
  18.         printf("Cipher: "); put8(work); printf("\n");
  19.         dedes(ks,work);
  20.         printf("Decrypted: "); put8(work); printf("\n");
  21.     }
  22. }
  23. get8(cp)
  24. char *cp;
  25. {
  26.     int i,t;
  27.  
  28.     for(i=0;i<8;i++){
  29.         scanf("%2x",&t);
  30.         *cp++ = t;
  31.     }
  32. }
  33. put8(cp)
  34. char *cp;
  35. {
  36.     int i;
  37.  
  38.     for(i=0;i<8;i++){
  39.         printf("%02x ",*cp++ & 0xff);
  40.     }
  41. }
  42.