note 111832 added to function.openssl-decrypt

From: Date: Wed, 03 Apr 2013 00:02:58 +0000
Subject: note 111832 added to function.openssl-decrypt
Groups: php.notes 
Request: Send a blank email to php-notes+get-194297@lists.php.net to get a copy of this message
in case that hosting do not provide openssl_encrypt decrypt functions - it could be mimiced via commad prompt executions this functions will check is if openssl is installed and try to use it by default function sslPrm() { return array("your_password","IV (optional)","aes-128-cbc"); } function sslEnc($msg) { list ($pass, $iv, $method)=sslPrm(); if(function_exists('openssl_encrypt')) return urlencode(openssl_encrypt(urlencode($msg), $method, $pass, false, $iv)); else return urlencode(exec("echo \"".urlencode($msg)."\" | openssl enc -".urlencode($method)." -base64 -nosalt -K ".bin2hex($pass)." -iv ".bin2hex($iv))); } function sslDec($msg) { list ($pass, $iv, $method)=sslPrm(); if(function_exists('openssl_decrypt')) return trim(urldecode(openssl_decrypt(urldecode($msg), $method, $pass, false, $iv))); else return trim(urldecode(exec("echo \"".urldecode($msg)."\" | openssl enc -".$method." -d -base64 -nosalt -K ".bin2hex($pass)." -iv ".bin2hex($iv)))); } //example of usage: $r= sslEnc("This is encryption/decryption test!"); echo "<br>\n".$r.":".sslDec($r); ---- Server IP: 69.147.83.199 Probable Submitter: 69.165.158.28 ---- Manual Page -- http://php.net/manual/en/function.openssl-decrypt.php Edit -- https://master.php.net/note/edit/111832 Del: integrated -- https://master.php.net/note/delete/111832/integrated Del: useless -- https://master.php.net/note/delete/111832/useless Del: bad code -- https://master.php.net/note/delete/111832/bad+code Del: spam -- https://master.php.net/note/delete/111832/spam Del: non-english -- https://master.php.net/note/delete/111832/non-english Del: in docs -- https://master.php.net/note/delete/111832/in+docs Del: other reasons-- https://master.php.net/note/delete/111832 Reject -- https://master.php.net/note/reject/111832 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#194297) next »