Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Generating alphanumeric gibberish?

Name: Anonymous 2010-01-12 14:58

What's a simple (preferably loopless) way to generate a large amount of alphanumeric gibberish? Any language is acceptable.

In PHP, I thought this would be perfect:

hexdec(mt_rand(1.e999999999, 1.e9999999999));

But it doesn't work due to restrictions on the length of int. :(

Name: Anonymous 2010-01-12 17:40

misaka@kuroko:~$ cat randtest.c
#include <stdio.h>

void randtext(char *out, int len) {
 static char chars[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmopqrstuvwxyz";
 while(len--)
  *out++ = chars[rand()%36];
}

char buf[100];
int main() {
 int i;
 for(i=0;i<100000;i++)
  randtext(buf,100);
 return 0;
}
misaka@kuroko:~$ cc -O2 -o randtest randtest.c
misaka@kuroko:~$ time ./randtest

real    0m0.018s
user    0m0.017s
sys     0m0.000s
misaka@kuroko:~$

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List