mkpasswd.c
wsh/src/util/mkpasswd.c · 938 B
From the archive wsh-147.tar.gz
Download the archive « Back to the archive contents
/* See the file wizshell.c, wizshell.h or the files in docs/ for information */
/* You really don't need this anymore, except to see what a password
* encryption would be
*/
#include <stdio.h>
#include <signal.h>
main(argc,argv)
int argc;
char **argv;
{
char c,buf[200],buf2[200];
if(argc==3) {
fprintf(stderr,"encrypted: %s\n",crypt(argv[1],argv[2]));
return;
}
if(argc!=1) {
fprintf(stderr,"Usage: mkpasswd [<password> <salt>]\n");
return;
}
signal(SIGINT, SIG_IGN);
system("stty -echo");
fprintf(stderr,"Password: ");
fgets(buf,200,stdin);
fprintf(stderr,"\nagain: ");
fgets(buf2,200,stdin);
fprintf(stderr,"\n");
system("stty echo");
signal(SIGINT, SIG_DFL);
if(strcmp(buf,buf2)) {
fprintf(stderr,"You changed.\n");
return;
}
fprintf(stderr,"salt: (any two characters) ");
fgets(buf2,200,stdin);
fprintf(stderr,"encrypted: %s\n",crypt(buf,buf2));
return;
}