I want to sign .pdf file digitally and after that to create attached signature file and detached signature file, using Crypt::OpenSSL::RSA.
This is what I did:
1. Initialization
my $s_pdf_file_to_sign = 'pdf_file_to_sign'; my $s_private_key_file = 'private_key_file'; my $s_cert_file = 'certificate_file';
2. Read .pdf file content
my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size, $atime,$mtime,$ctime,$blksize,$blocks) = stat $s_pdf_to_sign; open FILE, "<$s_pdf_to_sign" or die "no such file"; binmode FILE; my $s_pdf_to_sign_string; read FILE, $s_pdf_to_sign_string, $size; close FILE;
3.Read private key content:
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size, $atime,$mtime,$ctime,$blksize,$blocks) = stat $s_private_key; open FILE, "<$s_private_key" or die "no such file"; binmode FILE; my $s_private_key_content; read FILE, $s_private_key_content, $size; close FILE;
4. Create private_key object:
my $s_private_key_string = $s_private_key_content; my $oref_rsa_priv = Crypt::OpenSSL::RSA->new_private_key($s_private_ke +y_content) or die "new_private_key error";
5. Sign pdf file content:
my $signature = $oref_rsa_priv->sign($s_pdf_content);Could someone tell me what contains $signature variable? What should I do to create the attached and detached signatures?
In reply to Sign pdf file digitally by LoraIlieva
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |