1c2a8728095bb5188d825b6fc9842c23ba84d4e8
[users/jgh/exim.git] / test / aux-fixed / dkim / sign.pl
1 use Mail::DKIM::Signer;
2 use Mail::DKIM::TextWrap;  #recommended
3 use Getopt::Long;
4
5 my $method = "simple/simple";
6
7 GetOptions(
8         "method=s" => \$method,
9 );
10
11 # create a signer object
12 my $dkim = Mail::DKIM::Signer->new(
13                   Algorithm => "rsa-sha1",
14                   Method => $method,
15                   Domain => "test.ex",
16                   Selector => "sel",
17                   KeyFile => "aux-fixed/dkim/dkim.private",
18              );
19
20 # read an email and pass it into the signer, one line at a time
21 while (<STDIN>)
22 {
23       # remove local line terminators
24       chomp;
25       s/\015$//;
26
27       # use SMTP line terminators
28       $dkim->PRINT("$_\015\012");
29 }
30 $dkim->CLOSE;
31
32 # what is the signature result?
33 my $signature = $dkim->signature;
34 print $signature->as_string;
35 print "\n";
36
37 #print $dkim->headers;
38 #print "\n";