]>
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 | #include <unistd.h> |
a43ce477 | 14 | #ifdef USE_CRYPT_H |
15 | #include <crypt.h> | |
16 | #endif | |
b93ad422 | 17 | |
18 | /* Function Name: RemoveHyphens | |
19 | * Description: Removes all hyphens from the string passed to it. | |
20 | * Arguments: str - the string to remove the hyphes from | |
21 | * Returns: none | |
22 | */ | |
23 | ||
5eaef520 | 24 | void RemoveHyphens(char *str) |
b93ad422 | 25 | { |
5eaef520 | 26 | char *hyphen; |
b93ad422 | 27 | |
5eaef520 | 28 | while ((hyphen = strchr(str, '-'))) |
29 | strcpy(hyphen, hyphen + 1); | |
b93ad422 | 30 | } |
31 | ||
32 | ||
33 | /* Function Name: EncryptMITID | |
5eaef520 | 34 | * Description: Encrypts an mit ID number. |
b93ad422 | 35 | * Arguments: sbuf - the buffer to return the encrypted number in. |
36 | * idnumber - the id number (string). | |
37 | * first, last - name of the person. | |
38 | * Returns: none. | |
39 | */ | |
40 | ||
5eaef520 | 41 | void EncryptID(char *sbuf, char *idnumber, char *first, char *last) |
b93ad422 | 42 | { |
5eaef520 | 43 | char salt[3]; |
b93ad422 | 44 | |
5eaef520 | 45 | RemoveHyphens(idnumber); |
46 | salt[0] = tolower(last[0]); | |
47 | salt[1] = tolower(first[0]); | |
48 | salt[2] = '\0'; | |
b93ad422 | 49 | |
5eaef520 | 50 | strcpy(sbuf, crypt(&idnumber[2], salt)); |
b93ad422 | 51 | } |
52 |