note 116788 added to function.openssl-encrypt

From: Date: Sat, 28 Feb 2015 14:14:32 +0000
Subject: note 116788 added to function.openssl-encrypt
Groups: php.notes 
Request: Send a blank email to php-notes+get-201824@lists.php.net to get a copy of this message
Just a couple of notes about the parameters: data - It is interpreted as a binary string method - Regular string, make sure you check openssl_get_cipher_methods() for a list of the ciphers available in your server* password - As biohazard mentioned before, this is actually THE KEY! It should be in hex format. options - As explained in the Parameters section iv - Initialization Vector. Different than biohazard mentioned before, this should be a BINARY string. You should check for your particular implementation. To verify the length/format of your IV, you can provide strings of different lengths and check the error log. For example, in PHP 5.5.9 (Ubuntu 14.04 LTS), providing a 32 byte hex string (which would represent a 16 byte binary IV) throws an error. "IV passed is 32 bytes long which is longer than the 16 expected by the selected cipher" (cipher chosen was 'aes-256-cbc' which uses an IV of 128 bits, its block size). Alternatively, you can use openssl_cipher_iv_length(). From the security standpoint, make sure you understand whether your IV needs to be random, secret or encrypted. Many times the IV can be non-secret but it has to be a cryptographically secure random number. Make sure you generate it with an appropriate function like openssl_random_pseudo_bytes(), not mt_rand(). *Note that the available cipher methods can differ between your dev server and your production server! They will depend on the installation and compilation options used for OpenSSL in your machine(s). ---- Server IP: 72.52.91.14 Probable Submitter: 75.128.155.158 ---- Manual Page -- http://php.net/manual/en/function.openssl-encrypt.php Edit -- https://master.php.net/note/edit/116788 Del: integrated -- https://master.php.net/note/delete/116788/integrated Del: useless -- https://master.php.net/note/delete/116788/useless Del: bad code -- https://master.php.net/note/delete/116788/bad+code Del: spam -- https://master.php.net/note/delete/116788/spam Del: non-english -- https://master.php.net/note/delete/116788/non-english Del: in docs -- https://master.php.net/note/delete/116788/in+docs Del: other reasons-- https://master.php.net/note/delete/116788 Reject -- https://master.php.net/note/reject/116788 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#201824) next »