|
Here's a little 'C' program to encrypt passwords in case you want to add encrypted passwords to the shell script. It was tested under RedHat 9.0
/*
* cryptit.c
*
* simple program to encrypt 8 character passwords.
*
* compile command: gcc -lcrypt -o cryptit cryptit.c
*/
#include <unistd.h>
#include <stdio.h>
char seed [2];
char seedstart [3] = {'0', 'a', 'A'};
void setseed (void)
{
int i;
for (i=0; i < 2; i++) {
seed[i] = seedstart[random() % 3];
seed[i] += random() % (seed[i] == '0' ? 10 : 26);
}
}
main ()
{
char passwd[9];
char *cpasswd;
while (1) {
printf("Password (8 characters max.): ");
scanf ("%8s",passwd);
setseed();
cpasswd = crypt(passwd, seed);
printf ("The encrypted password for %s is %s\n", passwd, cpasswd);
}
}
Edit: added random seed generation.
Last edited by ovf; 07-24-2003 at 08:08 PM.
|