Home page logo
/

nmap-dev logo Nmap Development mailing list archives

Re: [Patch] KRAD Ascii Art (A short and sweet patch)
From: Daniel Miller <bonsaiviking () gmail com>
Date: Wed, 19 Mar 2014 15:18:51 -0500

On 03/19/2014 01:01 PM, Jay Bosamiya wrote:
Looking at the random number generator in awk, it seems to produce numbers that are very close to each other each time, so I felt that a better thing to do would be the following

   cat $(ls docs/leet-nmap-ascii-art*.txt 2>/dev/null | awk
   'BEGIN{srand();}{lines[++d]=$0}END{print
   lines[int(rand()*49139)%d+1]}') 2>/dev/null

It seems to work quite well then. (the 49139 is a prime number not close to a power of 2)
I don't have a problem with this, but in my testing using original-awk, mawk, and gawk, both methods had similar distributions when choosing random numbers between 1 and 5. Interestingly, mawk was about twice as fast as gawk, which was about twice as fast as original-awk in this (mostly useless) test.

Dan
_______________________________________________
Sent through the dev mailing list
http://nmap.org/mailman/listinfo/dev
Archived at http://seclists.org/nmap-dev/


  By Date           By Thread  

Current thread:
[ Nmap | Sec Tools | Mailing Lists | Site News | About/Contact | Advertising | Privacy ]