#!/usr/bin/perl
use GnuPG; $username=$ARGV[0]; $email=$ARGV[1]; $size=@ARGV; if($size!=2){ print "usage: gen_key.pl \n"; exit(0); } #$username="admin11";
#$email='seven.zhang@uniforce.net';
#system "/var/www/html/sstg/bin/create_account.pl $username";
#system "create_account.pl $username";
my $gpg = new GnuPG(); my $secret="123456"; sub gen_key_test { printf "%-40s", "Key generation"; $gpg->gen_key( passphrase => "$secret", name => "$username", email => "$email", comment=>"My GnuPG Key", );
}
sub export_secret_test { printf "%-40s", "Exporting secret pub key"; $gpg->export_keys( keys => "$username", secret => 0, armor => 1, output => "/home/$username/keyring.pub", ); } sub export_secret_test2 { printf "%-40s", "Exporting secret key"; $gpg->export_keys( keys => "$username", secret => 1, armor => 1, output => "/home/$username/keyring.sec", ); } my @tests = qw( gen_key_test export_secret_test export_secret_test2 ); if ( defined $ENV{TESTS} ) { @tests = split /\s+/, $ENV{TESTS}; }
print "1..", scalar @tests, "\n"; my $i = 1; for ( @tests ) { eval { no strict 'refs'; # We are using symbolic references
&$_(); }; if ( $@ ) { print "not ok $i: $@"; } else { print "ok $i\n"; } $i++; }
|