[OT] programming question

Andy Armstrong andy at hexten.net
Thu Apr 26 01:29:13 BST 2007


On 25 Apr 2007, at 23:26, Nicholas Clark wrote:
> So what's the best way to randomly permute the order of the  
> answers, store
> a small amount of state in a hidden field in the form, and  
> reproduce the
> permutation back on the next call to the server, such that it can  
> map back
> to the original answer order, without (too much) information leakage?

Do the field ids on the form have to be consecutive? Could you just  
XOR them with some constant and stuff that in a hidden field in a  
slightly munged form?

Or perhaps:

use List::Util qw(shuffle);

my $MAX_ID = 5;
my $SEED   = 123;

srand($SEED);
my @order = shuffle( 1 .. $MAX_ID );

# Build forward and reverse hashes
my %forward = map { $_ => $order[$_-1] } 1 .. $MAX_ID;
my %reverse = reverse %forward;



-- 
Andy Armstrong, hexten.net



More information about the london.pm mailing list