summaryrefslogtreecommitdiffstats
path: root/system/libraries
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2014-06-21 23:09:36 +0200
committerAndrey Andreev <narf@devilix.net>2014-06-21 23:09:36 +0200
commit42183de45621e09621399ee161135f995af552ff (patch)
tree740dfbc685d8780929684547c6e7e4ac2913ed7c /system/libraries
parent4191be3d3be76909253158a6cd35fbf3a89cfb5f (diff)
Add CI_Encryption::create_key()
This was planned, we somehow forgot about it. :)
Diffstat (limited to 'system/libraries')
-rw-r--r--system/libraries/Encryption.php15
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