Hi Jeff,

Well, this is my personal hack to generate an id based on some code by
Randal Schwartz.

sub generate_id {

my $id_letter_count                    = 4;
my $id_digit_count                     = 4;
#my $timeout                           = 100;

# excluded ASCII characters [91-96] 
my @letters                            = (65..90,97..122);
my @numbers                            = 0..9;

my $id;
  
GENID:

# if ($timeout > 0 && $timeout_counter < $timeout) {
{

  my @ids;

  for (1..$id_letter_count)            {    push @ids, chr(splice @letters,
rand(@letters), 1); }
  for (1..$id_digit_count)             {    push @ids, splice @numbers,
rand(@numbers), 1;  }

  # now put into a format to return
  map                                  { $id .= $_;   } @ids;

  # check if in use
  if (&check_if_in_use($id) ||
      $id !~
/\s*[a-zA-Z]{$id_letter_count,$id_letter_count}\d{$id_digit_count,$id_digit_
count}\s*/) {

     # found $id - retrying
     $id                               = '';
     #$timeout_counter++;
     goto GENID;
   
  }

}

return $id;

}



At 04:30 PM 04/06/00 -0500, you wrote:
>
>
>Well as another self-made programmer the idea occurs to me to grab the
>modules Crypt::DES or Crypt::IDEA from CPAN might provide either a fix, or
>at least insite into possible resolutions.
>
>Jeff
>
>
>
>
>
>CN=Jeff [EMAIL PROTECTED]> on 04/06/2000 03:02:38 PM
>
>Sent by:  "Martin A. Langhoff" <[EMAIL PROTECTED]>
>
>
>Sent From the mail file of:   Jeff Bulley
>
>
>To:   mod-perl Mailing List <[EMAIL PROTECTED]>
>cc:
>
>Subject:  [OT][General Programming] Key Generator sub
>
>
>hi list!
>
>    I'm guilty of being a self taught programmer, and so, from time to
>time, I find myself asking silly questions. Hope you don't mind too
>much.
>
>    [if you do, flame me privately, please ... lets keep my shame
>between the two of us]
>
>    ok, what I'm looking for is a poor man's crypt(). And a simple one,
>because whatever logic I use, I must reproduce in a limited proprietary
>language (Macromedia Director's "Lingo"). Lingo won't allow me to do bit
>math, 'xor' nor any sophisticated scheme. Plain math stuff and string
>manipulation.
>
>    On the other hand, neither the target audience nor the intended use
>is high end. It's just a quick lock to control the spreading of an app
>to no more than 100 users.
>    I won't be locking nuclear warheads with it :)
>
>    Is there any 'teaching book' example? Maybe a listmember with proper
>education can tell me?
>
>
>martin
>--                                                         --
>To understand recursion, one must first understand recursion.
>--                                                         --
>    - Martin Langhoff @ S C I M  Multimedia Technology -
>      - http://www.scim.net      | God is real until  -
>      - mailto:[EMAIL PROTECTED]  | declared integer   -
>
>
>
>
>
>

Reply via email to