Last active
January 20, 2016 17:00
Revisions
-
RDelorier revised this gist
Jan 20, 2016 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,7 +6,7 @@ * * @return string */ function encrypt($value) { $key = 'secret-key-here'; $cipher = 'AES-256-CBC'; -
RDelorier revised this gist
Jan 20, 2016 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,5 @@ <?php /** * Encrypts the value in a way compatible with laravel 5.1 * @param $value value to encrypt -
RDelorier created this gist
Jan 20, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ /** * Encrypts the value in a way compatible with laravel 5.1 * @param $value value to encrypt * * @return string */ private function encrypt($value) { $key = 'secret-key-here'; $cipher = 'AES-256-CBC'; $iv = openssl_random_pseudo_bytes(16); $value = openssl_encrypt(serialize($value), $cipher, $key, 0, $iv); $iv = base64_encode($iv); $mac = hash_hmac('sha256', $iv . $value, $key); $json = json_encode(compact('iv', 'value', 'mac')); return base64_encode($json); }