[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] crypt() fun



In article <20000613113552.J525@rahul.net>, Bennett Todd <bet@rahul.net> wrote:
> 	my $last = '';
> 	my $cur = random_string_gen();
> 	my @lag = ($cur);
> 	while (1) {
> 		$last = $cur;
> 		$cur = crypt($cur, $cur);
> 		last if $last eq $cur;
> 		$cur = random_string_gen() and @lag=($cur) if $lag[0] eq $cur;
> 		push @lag, $cur;
> 		$last = $cur;
> 		$cur = crypt($cur, $cur);
> 		last if $last eq $cur;
> 		$cur = random_string_gen() and @lag=($cur) if shift(@lag) eq $cur;
> 		if ($#lag > 10000) {
> 			$cur = random_string_gen();
> 			@lag = ($cur);
> 		} else {
> 			push @lag, $cur;
> 		}
> 	}

Ok, I give up trying to understand what this is supposed to accomplish.
Can you annotate it?

> or thereabouts. Naturally it'd be rather more painful to try and say
> this sort o' thing in C :-).

In C you would probably use a circular buffer (with start and end pointers)
in place of @lag.  I don't see anything inherently painful to do in C here.

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe