Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add signature into PDF in perl

How can I sign a pdf file using digital signature in perl? I'm able to extract the content of pdf and to generate signature string via

# $content -> pdf content to be signed

my $private_key Crypt::OpenSSL::RSA->new_private_key($key_string);
$private_key->use_md5_hash();
my $signature = $private_key->sign($content);

Consequently, the $signature can be converted into hex format, but I don't know how to add it into PDF file. I know that the signature in hex form should be placed in /Contents field and the range of signed text is given by /ByteRange array.

Is there any module for this purpose? Or can you give me any advice how to do it? Thanks

like image 583
user1753233 Avatar asked Nov 04 '22 14:11

user1753233


1 Answers

you may find this script interesting ... http://mschuette.name/files/pdfsign.pl it uses PDF::API2 and Crypt::OpenSSL todo its magic ... it could probably serve as a basis for creating something of your own.

like image 185
Tobi Oetiker Avatar answered Nov 08 '22 05:11

Tobi Oetiker