It looks like the encryption is getting closer, but not exact. From my php encrypted string, they always end in %3D. My perl encrytped string is slightly longer and ends in ...%3D%0A.
#!/usr/bin/perl use Crypt::CBC; use Crypt::Rijndael; use Digest::MD5 qw(md5_hex md5_base64); use MIME::Base64; use URI::Escape; sub encrypt{ my $data = shift; $data = &get16($data); my $key = "HELLOKEY"; my $key_size = 16; my $key_hash = md5_hex($key); $AESKEY = substr($key_hash,0,$key_size); print "AESKEY->".$AESKEY."\n"; my $iv= Crypt::CBC->random_bytes(16); my $cipher = Crypt::CBC->new( -key => $AESKEY, -cipher => 'Rijndael', -padding => 'rijndael_compat', -keysize => $keysize, -header => 'none', -iv =>$iv ); $iv = $cipher->get_initialization_vector(); my $encrypted = $cipher->encrypt($data); print "After encryption:$encrypted\n"; $encrypted = $iv.$encrypted; $encrypted = encode_base64($encrypted); print "After base 64 encoding:$encrypted\n\n"; $encrypted = uri_escape($encrypted); print "After url_encoding: $encrypted\n"; } &encrypt("test123");
Output: After encryption:ß7ý NÌÚNf"G¼èÈøö After base 64 encoding:W91lGKIvb4dyJhYx96ME2t83/YROzNpOZiJHvOjI+PY= After url_encoding: W91lGKIvb4dyJhYx96ME2t83%2FYROzNpOZiJHvOjI%2BPY%3D%0A

In reply to Re^4: Perl encryption not matching PHP encryption by johnnytc4
in thread Perl encryption not matching PHP encryption by johnnytc4

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.