File: cvspasswd.c

package info (click to toggle)
insighttoolkit 3.20.1%2Bgit20120521-3
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 80,652 kB
  • sloc: cpp: 458,133; ansic: 196,223; fortran: 28,000; python: 3,839; tcl: 1,811; sh: 1,184; java: 583; makefile: 430; csh: 220; perl: 193; xml: 20
file content (27 lines) | stat: -rw-r--r-- 599 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <errno.h>
 
main(argc, argv)
int argc;
char *argv[];
{
    time_t now;
    char salt[64];
 
    if (argc != 3) {
        fprintf(stderr, "Usage: mkpasswd [name] [passwd]\n");         exit(1);
    }
 
    if (time(&now)==-1) {
        fprintf(stderr, "System Error: time not available\n");         exit(1);
    }
 
    /* add a little salt to our crypt */
    sprintf(salt, "%s", ctime(&now));
    salt[0] = salt[17]; salt[1] = salt[18]; salt[2] = '\0';
 
    printf("%s:%s\n", argv[1], crypt(argv[2], salt));
    exit(errno);
}