From e7a3096b9cbd7c95bf4240c5233c7d14eb112305 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sun, 8 Mar 2015 22:15:57 +0200 Subject: [ci skip] Update CI_Encryption docs Close #3647 --- user_guide_src/source/libraries/encryption.rst | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'user_guide_src/source') diff --git a/user_guide_src/source/libraries/encryption.rst b/user_guide_src/source/libraries/encryption.rst index d445bf42f..5f0979da7 100644 --- a/user_guide_src/source/libraries/encryption.rst +++ b/user_guide_src/source/libraries/encryption.rst @@ -106,6 +106,18 @@ and set:: $config['encryption_key'] = 'YOUR KEY'; +You'll notice that the ``create_key()`` method outputs binary data, which +is hard to deal with (i.e. a copy-paste may damage it), so you may use +``bin2hex()``, ``hex2bin()`` or Base64-encoding to work with the key in +a more friendly manner. For example:: + + // Get a hex-encoded representation of the key: + $key = bin2hex($this->encryption->create_key(16)); + + // Put the same value in your config with hex2bin(), + // so that it is still passed as binary to the library: + $config['encryption_key'] = hex2bin(); + .. _ciphers-and-modes: Supported encryption ciphers and modes @@ -525,6 +537,15 @@ Class Reference Please refer to the :ref:`custom-parameters` secrion for information on the optional parameters. + .. php:method:: create_key($length) + + :param int $length: Output length + :returns: A pseudo-random cryptographic key with the specified length, or FALSE on failure + :rtype: string + + Creates a cryptographic key by fetching random data from + the operating system's sources (i.e. /dev/urandom). + .. php:method:: hkdf($key[, $digest = 'sha512'[, $salt = NULL[, $length = NULL[, $info = '']]]]) :param string $key: Input key material -- cgit v1.2.3-24-g4f1b