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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.