Wenn man ein paar kleinere webprojekte nebenbei betreut, kriegt man immer wieder lustige anfragen über mäjhl.
Seit ich es einmal erlebt habe, dass eines der von mir mitbetreuten projekte durch eine wörterbuchattacke übernommen wurde, lasse ich die menschen nicht mehr ihre passwörter selbst aussuchen, sondern gebe ihnen erstmal eines vor. Die meisten menschen kommen zum glück nicht auf die idee, dieses passwort zu ändern.
Als heute mal wieder jemand sein passwort vergaß und von mir schnell ein neues passwort bekam, da fragte mich dieser mensch, wie ich eigentlich immer auf meine passwörter komme, die sich viel leichter merken lassen als irgendwelche automatisch generierten passwörter. Nun, die antwort ist einfach: ich verwende hierzu ein programm. Und die passwörter sind leichter zu merken, weil dieses programm aussprechbare zeichenketten erzeugt. Ich bin eigentlich eher erstaunt, dass das nicht jeder so macht.
Wer auch immer wieder vor dem problem steht, anderen leuten passwörter zuteilen zu müssen, wird vielleicht das folgende C-programm mögen — es handelt sich um ANSI-C, das sich überall kompilieren lassen sollte. Allerdings muss es mindestens eine warnung wegen der uninitialisierten volatile
-Variablen geben, diese hat einen undefinierten wert. (Diese programmiertechnik empfehle ich niemanden zur nachahmung, es ist wirklich dreck.)
/* * * propass.c * Pronouncible Password Generator (ANSI C) * * Elias Schwerdtfeger, http://www.tamagothi.de/ * * This is FREE SOFTWARE, published under the terms of the PIRATE * LICENSE. This license allows you to do anything you like with * this little piece of code, as long as you do not sue me. ;-) * * The exact terms are available in german language at * http://www.tamagothi.de/lizenz/ * * $Id: propass.c,v 1.2 2008/11/10 07:04:14 elias Exp $ * */ #include <stdlib.h> #include <stdio.h> #include <string.h> #include <ctype.h> #include <time.h> /* * This function makes a weak rand() implementation a little more * obscure. It should not be necessary for modern std libs, but * old compilers for MS/DOS are bundled with a very weak rand() * implementation, so I better take a little care of it... */ static unsigned crnd (unsigned limit) { static int inited = 0; static int j = 19; volatile int dirtyhack; /* See comment below */ register int i; register unsigned int a; /* * This volatile variable "dirtyhack" gets a value from the stack, * which is obscure and shold generate a compiler warning. The * usage of such an uninited var is the worst way in generating * some randomness I ever coded, and it may (must) be changed in * later versions. */ if (!inited) { srand (j = (int) time (NULL)); inited = 1; } j = ((3 * j + 7 + dirtyhack) & 31) + 9; for (i = 0, a = 0; i < j; ++i) { a *= 31; a ^= rand (); } return a % limit; } static char * propass (void) { static char buf[128]; static char vow[] = "aeiou"; static char cst[] = "bdfgjklmnprstvz--"; static char cen[] = "fklmnprstx------"; static unsigned vow_l = 0; static unsigned cst_l = 0; static unsigned cen_l = 0; int i; int bp; int dgtpos; if (!vow_l) { vow_l = strlen (vow); cst_l = strlen (cst); cen_l = strlen (cen); } dgtpos = crnd (3) + 1; for (i = bp = 0; i < 5; ++i) { if (i == dgtpos) { int r; char tb_a[4]; char *tb = tb_a; r = crnd (999) + 1; sprintf (tb, "%03d", r); for (; *tb; ++tb) buf[bp++] = *tb; } else { char c1 = cst[crnd (cst_l)]; char c2 = vow[crnd (vow_l)]; char c3 = cen[crnd (cen_l)]; if (isalpha (c1)) buf[bp++] = c1; if (isalpha (c2)) buf[bp++] = c2; if (isalpha (c3)) buf[bp++] = c3; } } buf[bp] = 0; return buf; } int main (int argc, char **argv) { char *id = "$Id: propass.c,v 1.2 2008/11/10 07:04:14 elias Exp $"; int n = 3; int i; switch (argc) { case 0: /* This may occur on Amiga OS ;-) */ case 1: break; case 2: if (isdigit (argv[1][0])) { n = atoi (argv[1]); } else { fprintf (stderr, "Pronouncible passwords\n%s\n", id); return EXIT_FAILURE; } break; default: fprintf (stderr, "Too many arguments\n"); return EXIT_FAILURE; } if (n > 1) { printf ("Choose from the following %d password suggestions\n", n); for (i = 0; i < n; ++i) printf ("%d: %s\n", i + 1, propass ()); } else { printf ("%s\n", propass ()); } return EXIT_SUCCESS; } /* * * $Log: propass.c,v $ * Revision 1.2 2008/11/10 07:04:14 elias * Random number generation is a little more obscure now. * * Revision 1.1 2008/10/11 12:21:46 elias * Initial revision * */
Ich hoffe, es hilft auch anderen.