$rword
Posted by Direkii
Friday, August 12, 2005
Description: randomness of letters/numbers


alias rword {
  var %num = $iif(!$1,$rand(1,50),$1)
  var %i = 1
  while (%i <= %num) {
    var %c = $rand(1,2)
    if (%c == 1) {
      var %word = %word $+ $rand(1,9) $+
      inc %i
    }
    if (%c == 2) {
      var %word = %word $+ $rand(A,z) $+
      inc %i
    }
  }
  return %word
}


//echo -a $rword(255) returns
h96G548IGhw1m8931j5JR29oLwd1y2T`1Q47xwufXp^2936mD767iM5r786W1pyq4Be5S_V1XtA5`T^69[v5929Z8B3991684181NCl2VIC7IRA12[C2Z222ic2234x4S9jAZ79\Ao6w1s981Qv16Ly8z836w\2k1635t9Og81r4673gSc488x8y9i1cqO846U6U38161J824ksi7vxQ3q5B9zrx898WP83ayS6836G19M9882sC1w826M3K94r
hmmm...
Posted by drakky
Friday, August 12, 2005 08:54pm PDT
It's alright I guess
regsubex
Posted by mackhil
Saturday, June 24, 2006 06:21pm PDT
Since mIRC 6.17 you can use $regsubex to perform this in one line.

alias rword return $regsubex($str(x,$1),/./g,$mid(aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ0123456789,$r(1,62),1))

Same useage as the above snippet. It's also much faster when mass generating. In a test code, generating 5000 passwords, the original snippet took about 5.6s where as using $regsubex took 2.1s. That's nearly 3x faster.

The results are also far more balanced (letters to number ratio).
Submit a comment
Oops! You need to login or register before you can post a comment!

ebaum's world