User Tools

Site Tools


a.pl
#!/usr/bin/env perl
 
my $hostname = 'www.gnu.org';
 
use Digest::MD5 qw(md5_hex);
 
sub do_client_hash {
    my $hostname = shift;
    my $salt = '1234567890';
    my $hash = md5_hex($hostname . $salt);
    $hash;
}
 
my $client_hash = do_client_hash($hostname);
 
sub do_provider_hash {
    my $client_hash = shift;
    my $time = shift;
    my $salt = '1234567890';
    $time . ':' . md5_hex($client_hash . $time . $salt);
}
 
my $last = '1516895592';
 
my $key = do_provider_hash($client_hash, $last);
 
print $key, "\n";
 
sub check {
    my $product_key = shift;
    my $hostname = shift;
    my ($time, $hash) = split /:/, $product_key;
    my $salt1 = '1234567890';
    my $salt2 = '1234567890';
 
    my $hash1 = md5_hex($hostname . $salt1);
    my $hash2 = md5_hex($hash1 . $time . $salt2);
 
    if ($hash eq $hash2 and time < ($time + 0)) {
        print "OK\n" ;
    } else {
        print "NO\n" ;
 
    }
}
 
 
my $key2 = '1516895592:3aea160fcdc800e26b0e21bc0c9cec5f';
check ($key2, $hostname);
 
my $key2 = '1576895592:3aea160fcdc800e26b0e21bc0c9cec5f';
check ($key2, $hostname);

Back to overviewNext PageLast Page