You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: user_guide_src/source/libraries/encryption.rst
+68-61Lines changed: 68 additions & 61 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,40 +3,41 @@ Encryption Service
3
3
##################
4
4
5
5
.. important:: DO NOT use this or any other *encryption* library for
6
-
user password storage! Passwords must be *hashed* instead, and you
7
-
should do that via PHP's own `Password Hashing extension
6
+
password storage! Passwords must be *hashed* instead, and you
7
+
should do that through PHP's `Password Hashing extension
8
8
<http://php.net/password>`_.
9
9
10
10
The Encryption Service provides two-way symmetric (secret key) data encryption.
11
-
The encryption manager will instantiate and/or initialize an
12
-
encryption handler to suit your parameters, explained below.
11
+
The service will instantiate and/or initialize an
12
+
encryption **handler** to suit your parameters as explained below.
13
13
14
-
The handlers adapt our simple ``EncrypterInterface`` to use an
15
-
appropriate PHP cryptographic extension or third party library.
16
-
Such extensions may need to be explicitly enabled in your instance of PHP.
14
+
Encryption Service handlers must implement CodeIgniter's simple ``EncrypterInterface``.
15
+
Using an appropriate PHP cryptographic extension or third-party library may require
16
+
additional software is installed on your server and/or might need to be explicitly
17
+
enabled in your instance of PHP.
17
18
18
-
The following extensions are currently supported:
19
+
The following PHP extensions are currently supported:
19
20
20
21
- `OpenSSL <http://php.net/openssl>`_
21
22
23
+
This is not a full cryptographic solution. If you need more capabilities, for example,
24
+
public-key encryption, we suggest you consider direct use of OpenSSL or
25
+
one of the other `Cryptography Extensions <https://www.php.net/manual/en/refs.crypto.php>`_.
26
+
A more comprehensive package like `Halite <https://github.com/paragonie/halite>`_
27
+
(an O-O package built on libsodium) is another possibility.
28
+
22
29
.. note:: Support for the ``MCrypt`` extension has been dropped, as that has
23
30
been deprecated as of PHP 7.2.
24
31
25
-
This is not a full cryptographic solution. If you need more capabilities,
26
-
for instance public key encryption, we suggest you consider using the
27
-
above extensions directly, or look into some of the more comprehensive
28
-
packages, like:
29
-
30
-
- `Halite <https://github.com/paragonie/halite>`_, an O-O package built on libsodium, or
31
-
- `Sodium_compat <https://github.com/paragonie/sodium_compat>`_, a pure PHP implementation that adds libsodium support to earlier versions of PHP (5.2.4+)
32
-
33
32
.. contents::
34
33
:local:
35
34
36
35
.. raw:: html
37
36
38
37
<divclass="custom-index container"></div>
39
38
39
+
.. _usage:
40
+
40
41
****************************
41
42
Using the Encryption Library
42
43
****************************
@@ -45,12 +46,12 @@ Like all services in CodeIgniter, it can be loaded via ``Config\Services``::
45
46
46
47
$encrypter = \Config\Services::encrypter();
47
48
48
-
Assuming you have set your starting key (see below),
49
-
encrypting and decrypting data is simple - pass the appropriate string to the
50
-
``encrypt()`` and/or ``decrypt()`` methods::
49
+
Assuming you have set your starting key (see :ref:`configuration`),
50
+
encrypting and decrypting data is simple - pass the appropriate string to ``encrypt()``
51
+
and/or ``decrypt()`` methods::
51
52
52
-
$plain_text = 'This is a plain-text message!';
53
-
$ciphertext = $encrypter->encrypt($plaintext);
53
+
$plainText = 'This is a plain-text message!';
54
+
$ciphertext = $encrypter->encrypt($plainText);
54
55
55
56
// Outputs: This is a plain-text message!
56
57
echo $encrypter->decrypt($ciphertext);
@@ -61,61 +62,60 @@ You don't need to worry about it.
61
62
62
63
.. _configuration:
63
64
64
-
Configuring the library
65
+
Configuring the Library
65
66
=======================
66
67
67
-
The example above uses the default configuration settings,
68
-
found in ``application/config/Encryption.php``.
68
+
The example above uses the configuration settings found in ``app/Config/Encryption.php``.
0 commit comments