]>
Commit | Line | Data |
---|---|---|
fa59b86f | 1 | /* $Id$ |
b93ad422 | 2 | * |
7ac48069 | 3 | * Routines to deal with MIT IDs |
babbc197 | 4 | * |
7ac48069 | 5 | * Copyright (C) 1988-1998 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> |
7ac48069 | 11 | #include <moira.h> |
12 | ||
b93ad422 | 13 | #include <ctype.h> |
7ac48069 | 14 | #include <string.h> |
15 | ||
ea0caf4a | 16 | #ifdef HAVE_CRYPT_H |
a43ce477 | 17 | #include <crypt.h> |
7ac48069 | 18 | #else |
19 | #include <unistd.h> | |
a43ce477 | 20 | #endif |
b93ad422 | 21 | |
22 | /* Function Name: RemoveHyphens | |
23 | * Description: Removes all hyphens from the string passed to it. | |
24 | * Arguments: str - the string to remove the hyphes from | |
25 | * Returns: none | |
26 | */ | |
27 | ||
5eaef520 | 28 | void RemoveHyphens(char *str) |
b93ad422 | 29 | { |
5eaef520 | 30 | char *hyphen; |
b93ad422 | 31 | |
5eaef520 | 32 | while ((hyphen = strchr(str, '-'))) |
33 | strcpy(hyphen, hyphen + 1); | |
b93ad422 | 34 | } |
35 | ||
36 | ||
37 | /* Function Name: EncryptMITID | |
5eaef520 | 38 | * Description: Encrypts an mit ID number. |
b93ad422 | 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 | ||
5eaef520 | 45 | void EncryptID(char *sbuf, char *idnumber, char *first, char *last) |
b93ad422 | 46 | { |
5eaef520 | 47 | char salt[3]; |
b93ad422 | 48 | |
5eaef520 | 49 | RemoveHyphens(idnumber); |
50 | salt[0] = tolower(last[0]); | |
51 | salt[1] = tolower(first[0]); | |
52 | salt[2] = '\0'; | |
b93ad422 | 53 | |
5eaef520 | 54 | strcpy(sbuf, crypt(&idnumber[2], salt)); |
b93ad422 | 55 | } |
56 |