]> andersk Git - moira.git/blame_incremental - lib/idno.c
use CODE=ANSI_C option to proc
[moira.git] / lib / idno.c
... / ...
CommitLineData
1/* $Header$
2 *
3 * Routines to encrypt ID's
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>.
8 */
9
10#include <mit-copyright.h>
11#include <string.h>
12#include <ctype.h>
13#include <unistd.h>
14#ifdef USE_CRYPT_H
15#include <crypt.h>
16#endif
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
24void RemoveHyphens(char *str)
25{
26 char *hyphen;
27
28 while ((hyphen = strchr(str, '-')))
29 strcpy(hyphen, hyphen + 1);
30}
31
32
33/* Function Name: EncryptMITID
34 * Description: Encrypts an mit ID number.
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
41void EncryptID(char *sbuf, char *idnumber, char *first, char *last)
42{
43 char salt[3];
44
45 RemoveHyphens(idnumber);
46 salt[0] = tolower(last[0]);
47 salt[1] = tolower(first[0]);
48 salt[2] = '\0';
49
50 strcpy(sbuf, crypt(&idnumber[2], salt));
51}
52
This page took 0.420671 seconds and 5 git commands to generate.