Source:  Generate Encrypted Password

                                                                                Instructions

#include

#include

/* 1st param is the desired password */

/* A random seed (2 chars) will be */

/* automatically chosen. */

/* For good passwords: */

/* Use random chars, mixed apha- */

/* numerics and MiXeD CaSe for */

/* better protection. */

 

main(argc, argv)

int argc;

char *argv[];

{

char salt[3];

char *EncryptedPasswd;

int CheckRand;

int Fixup;

int SeedChar;

/* printf("\nUsage: pw \n\n"); */

/* Generate a random starting point for seed characters */

srand(time(NULL));

for ( SeedChar = 0; SeedChar <= 1; SeedChar++) {

CheckRand = 46 + rand() % 76; /* random number from 46 to 122 */

Fixup = 7 + rand() % 13; /* random number from 7 to 20 */

salt[SeedChar] = toascii(((CheckRand >= 58 && CheckRand <= 64) ||

(CheckRand >= 91 && CheckRand <= 96) ? CheckRand + Fixup :

CheckRand));

}

EncryptedPasswd=crypt(argv[1], salt);

/* printf("\nRequested pw= %s, Automatic Seed= %s, en-crypted pw= %s\n", */

/* argv[1], salt, EncryptedPasswd); */

printf("%s\n", EncryptedPasswd);

}

 

 

    

 Copyright © 2007 NEWFDAWG.COM All rights reserved.     Last modified: 02/03/07.