May I recommend two improvements?
If you're ok with there being only a single chain — I'd even think it was preferable — then
@matching{@names} = shuffle(@names); # Match 'em up # No one has themselves foreach (@names) { next GENERATE if $_ eq $matching{$_}; }
simplifies to
%matching = ( map { $_, $_ } @names )[ 1..@names*2-1, 0 ];
Another common limit is that B doesn't give to A if A gave to B the previous year. That can be achieved by changing
push @digest, md5_hex($_, '=>', $matching{$_});
to
push @digest, md5_hex(join '<=>', sort $_, $matching{$_});
someone actually bothers to try to crack it
That's *very* easy to do. Say you have "N" participants.
It's even easier than attacking passwords of length 2. Hashing the pairings is merely security theatre. You might as well MIME::Base64 them.
In reply to Re^2: Temporarily Obscuring a Lottery Draw
by ikegami
in thread Temporarily Obscuring a Lottery Draw
by kennethk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |