home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume29 / libdes / part01 / string_to_key.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-04-04  |  533 b   |  24 lines

  1. /* string_to_key.c */
  2. /* Copyright (C) 1992 Eric Young - see COPYING for more details */
  3. #include "des_local.h"
  4.  
  5. int des_string_to_key(str,key)
  6. char *str;
  7. des_cblock *key;
  8.     {
  9.     des_key_schedule ks;
  10.     int i,length;
  11.  
  12.     bzero(key,8);
  13.     length=strlen(str);
  14.     for (i=0; i<length; i++)
  15.         (*key)[i%8]^=(str[i]<<1);
  16.     des_set_odd_parity((des_cblock *)key);
  17.     des_set_key((des_cblock *)key,ks);
  18.     des_cbc_cksum((des_cblock *)str,(des_cblock *)key,(long)length,ks,
  19.         (des_cblock *)key);
  20.     bzero(ks,sizeof(ks));
  21.     des_set_odd_parity(key);
  22.     return(0);
  23.     }
  24.