Akopia Akopia Services

[Date Prev][Date Next][Thread Prev][Thread Next][Minivend by date ][Minivend by thread ]

[ic] Random password generator usertag



Hi,

I've create a usertag for random generation password that I use on my IC
server and I want to send it if other need similar function. I use this tag
for generate password and send it by email to new user account.

I've change my new_account.html file for use this new usertag :

+ [seti randpass][generate_password][/seti]
- <INPUT TYPE=password NAME=mv_password VALUE="">
+ <INPUT TYPE=hidden NAME=mv_password VALUE="[scratch randpass]">
- <INPUT TYPE=password NAME=mv_verify VALUE="">
+ <INPUT TYPE=hidden NAME=mv_verify VALUE="[scratch randpass]">

== CUT ==
UserTag generate_password Interpolate
UserTag generate_password Routine <<EOR
sub {
  my $dict = '/usr/dict/words'; # path to dict file
  my $wordlen = 10;             # desired length of the password
  my $sublen = 4;               # length of the word chunks that create the
password
  my $inline ;                  #
  my $sep = "\n" ;              # Line separator
  my @dict;

  $wordlen >= $sublen || die "Error: The word length should be equal or
larger than the length of the 'chunks'\n";

  $inline = ::readfile($dict) if $dict;
  my @dict = split /$sep/, $inline;

  my @sub = ();
  my $word = '';
  my $parts = int ($wordlen/$sublen);

  for (my $i=0;$i < $parts; $i++) {
    do {
      $sub[$i] = substr ($dict[int (rand @dict)], 0, $sublen);
    }
    until (length $sub[$i] == $sublen);
    $word .= lc $sub[$i];
  }

  my $left = $wordlen % $sublen;
  $word .= substr (int rand (10**($wordlen - 1)), 0, $left);

  return $word ;
}
EOR

== CUT ==



_______________________________________________
Interchange-users mailing list
Interchange-users@www.minivend.com
http://www.minivend.com/mailman/listinfo/interchange-users


Search for: Match: Format: Sort by: