diff options
Diffstat (limited to 'system/libraries/Encryption.php')
-rw-r--r-- | system/libraries/Encryption.php | 15 |
1 files changed, 15 insertions, 0 deletions
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 @@ -310,6 +310,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 * * @param string $data Input data |