Administration: can edit exercices

This commit is contained in:
nemunaire 2014-01-14 16:13:58 +01:00
parent a229a10f25
commit 868e3403ee

View File

@ -5,6 +5,8 @@ use strict;
use warnings;
use DBI;
use File::Basename;
use Digest::MD5 qw(md5_hex);
use Digest::SHA qw(sha1_hex sha224_hex sha256_hex sha384_hex sha512_hex);
#Return number of good solutions
my $exit = 0;
@ -75,13 +77,35 @@ for my $f (readdir $dh)
my $type = @$row[0];
my $sol = @$row[1];
if ($type eq "raw" && $sol ne $solution) {
$good = 0;
last;
my $tmp_solution = $solution;
if ($type eq "md5") {
$tmp_solution = md5_hex($solution);
}
elsif ($type eq "sha1") {
$tmp_solution = sha1_hex($solution);
}
elsif ($type eq "sha224") {
$tmp_solution = sha224_hex($solution);
}
elsif ($type eq "sha256") {
$tmp_solution = sha256_hex($solution);
}
elsif ($type eq "sha384") {
$tmp_solution = sha384_hex($solution);
}
elsif ($type eq "sha512") {
$tmp_solution = sha512_hex($solution);
}
elsif ($type ne "raw") {
$good = 0;
warn "$type not implemented";
}
say STDERR "check: $sol vs $tmp_solution";
if ($sol ne $tmp_solution)
{
$good = 0;
last;
}
}