Help for this page

Select Code to Download


  1. or download this
    use Digest::MD5;
    
    # Given a message and key, returns a message authentication code
    ...
        my $mac   = compute_mac(int($score), $secret);
        "$score/$mac";
    }
    
  2. or download this
    use CGI;
    use CGI::Cookie;
    
    ...
    $score     = authenticated_score($score);
    my $cookie = CGI::Cookie->new(-name => 'score', -value => $score);
    print header(-cookie=>$cookie);
    
  3. or download this
    my %cookies = CGI::Cookie->fetch;
    $score = $cookies{score}->value;
    
    # Eliminate any score that's been tampered with
    $score = 0 unless $score eq authenticated_score($score);
    
  4. or download this
    my %cookies = CGI::Cookie->fetch;
    my $score = $cookies{score}->value;
    $score = 0 unless $score eq authenticated_score($score);
    ...
    print header(-cookie=>$cookie);
    
    # (send the rest of your HTML to the player.)