From 42183de45621e09621399ee161135f995af552ff Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sun, 22 Jun 2014 00:09:36 +0300 Subject: Add CI_Encryption::create_key() This was planned, we somehow forgot about it. :) --- system/libraries/Encryption.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'system/libraries/Encryption.php') diff --git a/system/libraries/Encryption.php b/system/libraries/Encryption.php index d6ffc9bfe..aa91cd3f9 100644 --- a/system/libraries/Encryption.php +++ b/system/libraries/Encryption.php @@ -309,6 +309,21 @@ class CI_Encryption { // -------------------------------------------------------------------- + /** + * Create a random key + * + * @param int $length Output length + * @return string + */ + public function create_key($length) + { + return ($this->_driver === 'mcrypt') + ? mcrypt_create_iv($length, MCRYPT_DEV_URANDOM) + : openssl_random_pseudo_bytes($length); + } + + // -------------------------------------------------------------------- + /** * Encrypt * -- cgit v1.2.3-24-g4f1b