]>
Commit | Line | Data |
---|---|---|
b93ad422 | 1 | /* $Header$ |
2 | * | |
3 | * Routines to encrypt ID's | |
babbc197 | 4 | * |
5 | * (c) Copyright 1988 by the Massachusetts Institute of Technology. | |
6 | * For copying and distribution information, please see the file | |
7 | * <mit-copyright.h>. | |
b93ad422 | 8 | */ |
9 | ||
babbc197 | 10 | #include <mit-copyright.h> |
8fd777cf | 11 | #include <string.h> |
b93ad422 | 12 | #include <ctype.h> |
a43ce477 | 13 | #ifdef POSIX |
14 | #include <unistd.h> | |
15 | #endif | |
16 | #ifdef USE_CRYPT_H | |
17 | #include <crypt.h> | |
18 | #endif | |
b93ad422 | 19 | |
20 | /* Function Name: RemoveHyphens | |
21 | * Description: Removes all hyphens from the string passed to it. | |
22 | * Arguments: str - the string to remove the hyphes from | |
23 | * Returns: none | |
24 | */ | |
25 | ||
26 | void | |
27 | RemoveHyphens(str) | |
28 | char *str; | |
29 | { | |
30 | char *hyphen; | |
31 | ||
8fd777cf | 32 | while ((hyphen = strchr(str, '-')) != (char *)0) |
b93ad422 | 33 | (void) strcpy(hyphen, hyphen + 1); |
34 | } | |
35 | ||
36 | ||
37 | /* Function Name: EncryptMITID | |
38 | * Description: Encrypts an mit ID number. | |
39 | * Arguments: sbuf - the buffer to return the encrypted number in. | |
40 | * idnumber - the id number (string). | |
41 | * first, last - name of the person. | |
42 | * Returns: none. | |
43 | */ | |
44 | ||
45 | void | |
46 | EncryptID(sbuf, idnumber, first, last) | |
47 | char *sbuf, *idnumber, *first, *last; | |
48 | { | |
49 | char salt[3]; | |
b93ad422 | 50 | |
51 | RemoveHyphens(idnumber); | |
52 | salt[0] = tolower(last[0]); | |
53 | salt[1] = tolower(first[0]); | |
54 | salt[2] = 0; | |
55 | ||
56 | (void) strcpy(sbuf, crypt(&idnumber[2], salt)); | |
57 | } | |
58 |