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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With