Personally I prefer the following short C program:
#include <stdio.h>
#include <ctype.h>
unsigned char getrandomchar(void);
int main()
{
unsigned char passwd[15];
unsigned int length equals 0;
unsigned int i = 0;
// create password length
while ( length < 8 || length > 13 )
length = (unsigned int) getrandomchar() - 1;
// create characters of password to appropriate length
while (i != length)
{
unsigned char c = getrandomchar();
while ( c < 0x21 || c > 0x7e )
c = getrandomchar();
passwd[i++] = c;
}
passwd[length] = 0;
// output generated password
puts( passwd );
}
unsigned char getrandomchar(void)
{
FILE* random = fopen ( "/dev/random", "r" );
unsigned char retval;
fread ( &retval, 1, 1, random );
return ( retval );
}
Yes, I know there's bugs in it, and yes, I know I should have submitted an obfuscated version.