I am trying to do the following:
encode_json() -> $cipher->encrypt() -> encode_base64() -> <a href> ->
decode_base64() -> $cipher->decrypt() -> decode_json() -> Dumper()
It seems pretty straight forward but for some reason it is not working.
It breaks down at the $cipher->decrypt() part.
Any suggestions? Could it be an embperl issue or perl issue?
Thank You,
~Donavon
*temp.epl*
[- use JSON; # imports encode_json, decode_json, to_json and
from_json. use MIME::Base64; use Mycopa::Encrypt;
$encrypt = new Mycopa::Encrypt(); # set up json
%json = (); $json{TOR} = time; # set
up options %opts = (); $opts{option1} =
"Option 1"; $opts{option2} = "Option 2";
$opts{option3} = "Option 3"; push(@{ $json{opts} }, {%opts} );
$json = encode_json(\%json); $escmode = 0; print OUT $json
. "<br />"; # encrypt $cipher = Crypt::CBC->new(
-literal_key => 1, -key =>
"95A8EE8E89979B9EFDCBC6EB9797528D", -header => 'none',
-iv => "1234567890abcdef",
-cipher => 'Crypt::OpenSSL::AES' ); $plaintext =
$cipher->encrypt($json); $escmode = 0; print OUT $plaintext .
"<br />"; # encode $plaintextbase64 = encode_base64($plaintext);
# make URL friendly $plaintextbase64 =~ s/\+/-/g;
$plaintextbase64 =~ s/\//_/g; $plaintextbase64 =~ s/=/,/g;
$plaintextbase64 =~ s/\n//g; $escmode = 0; print OUT
$plaintextbase64 . "<br />"; -] <a href="temp1.epl?plaintextbase64=[+
$plaintextbase64 +]">Click Me!!!</a> *temp1.epl *
[- use JSON; # imports encode_json, decode_json, to_json and from_json.
use MIME::Base64; use Mycopa::Encrypt; $encrypt = new Mycopa::Encrypt();
$escmode = 0; print OUT $fdat{plaintextbase64} . "<br />"; # decode
$plaintextbase64 = decode_base64($fdat{plaintextbase64}); $escmode = 0;
print OUT $plaintextbase64 . "<br />"; # decrypt $cipher =
Crypt::CBC->new( -literal_key => 1, -key =>
"95A8EE8E89979B9EFDCBC6EB9797528D", -header => 'none', -iv =>
"1234567890abcdef", -cipher => 'Crypt::OpenSSL::AES' ); $plaintext =
$cipher->decrypt($plaintextbase64); $escmode = 0; print OUT $plaintext .
"<br />"; $json = decode_json($plaintext); use Data::Dumper;
$Data::Dumper::Sortkeys = 1; $escmode = 0; print OUT "<pre>"; print OUT
Dumper(\$json); print OUT "</pre>"; -]
**