PERL sample code for the signature calculation
# Required Perl Libraries.
use Digest::HMAC_SHA1;
use MIME::Base64;
use 5.006;
use strict;
use warnings;
sub decode_parsafe_base64 {
my($content) = @_;
# replace '+' by '-', and '/' by '_'
$content =~ tr/-/\+/;
$content =~ tr/_/\//;
return decode_base64($content);
}
sub encode_parsafe{
my($content) = @_;
$content =~ tr/\+/\-/;
$content =~ tr/\//\_/;
return $content;
}
sub sign_par {
my($par) = @_;
# Private Key - Replace with your private key.
my $KEY_STRING = 'YOUR_PRIVATE_KEY';
# Decode the private key into original binary format.
my $key = decode_parsafe_base64($KEY_STRING);
# Create HMAC-SHA1 Signature
my $digest = Digest::HMAC_SHA1->new($key);
$digest->add($par);
# Encode binary signature.
my $signature = $digest->b64digest;
# Make Signature PAR safe
$signature = encode_parsafe($signature);
return ( $signature )
}
# Replace with your PAR to be signed.
my $par = "COMMAND_ITEM_TO_SIGN";
my $signed_par = sign_par($par);
print $signed_par . "\n";