Date: Mon, 24 Mar 2003 06:04:57 +0100 (CET) From: sigsegv@login.kvalito.no (Jan-Espen Pettersen) To: tony@idk.com Cc: questions@freebsd.org Subject: Re: Generating passwords Message-ID: <20030324050457.8F4841276DA@login.kvalito.no>
next in thread | raw e-mail | index | archive | help
On Monday 24 March 2003 05:38, Tony wrote:
> Is there a program that will give unique passwords to be as login
> passwords. I seems to always stumble over deciding what it do.
>
> Idealy the program would do somethin like running the backgound generating
> passwords or random numbers and when asked generate a login password...
>
> Thanks
>
This C program will generate random passwords.
/* Copyright (C) Jan-Espen Pettersen
* This software is distributed WITHOUT ANY WARRANTY
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
int min_lenght = 8;
int max_lenght = 30;
int a;
long int b;
char *c = "-abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ---_/*+1234567890!#---1234567890-";
char *d;
long int e;
srandomdev();
e = random();
e = min_lenght + (e % ((max_lenght - min_lenght) + 1));
printf("lenght=%d\n", e);
e++;
d = (char *) malloc(e);
e--;
d[e] = 0;
a = 0;
while (a < e)
{
b = random();
b = b % strlen(c);
d[a] = c[b];
a++;
};
printf("password=\"%s\"\n", d);
};
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030324050457.8F4841276DA>
