|
static | create_key (?string $method=null, bool $chmod=true) |
| Creates a key for the server.
|
|
static | decrypt (string $data) |
| Decrypts data using the server's key.
|
|
static | encrypt (string $data, ?string $method=null) |
| Encrypts data using the server's key.
|
|
static | get_key_file (?string $method=null) |
| Gets the file path used to store the secret key.
|
|
static | is_sodium_installed () |
| Checks if Sodium is installed.
|
|
static | key_exists (?string $method=null) |
| Checks if there is a key file.
|
|
|
string const | METHOD_OPENSSL = 'openssl-aes-256-ctr' |
| Encryption method: hand-coded OpenSSL (less safe)
|
|
string const | METHOD_SODIUM = 'sodium' |
| Encryption method: Sodium.
|
|
string const | OPENSSL_CIPHER = 'AES-256-CTR' |
| OpenSSL cipher method.
|
|
|
static | get_encryption_method () |
| Gets the encryption method to use.
|
|
static | get_iv_length (string $method) |
| Gets the length in bytes of the initial values data required.
|
|
static | get_key (?string $method=null) |
| Gets the current key, automatically creating it if there isn't one yet.
|
|
static | get_key_folder () |
| Gets the folder used to store the secret key.
|
|
◆ create_key()
static core\encryption::create_key |
( |
?string | $method = null, |
|
|
bool | $chmod = true ) |
|
static |
Creates a key for the server.
Note we currently retain support for all methods, in order to decrypt legacy {
- See also
- METHOD_OPENSSL} content
- Parameters
-
string | null | $method | Encryption method (only if you want to create a non-default key) |
bool | $chmod | If true, restricts the file access of the key |
- Exceptions
-
◆ decrypt()
static core\encryption::decrypt |
( |
string | $data | ) |
|
|
static |
Decrypts data using the server's key.
The decryption works with either supported method.
Note currently we retain support for all methods, in order to decrypt legacy {
- See also
- METHOD_OPENSSL} content
- Parameters
-
string | $data | Data to decrypt |
- Return values
-
◆ encrypt()
static core\encryption::encrypt |
( |
string | $data, |
|
|
?string | $method = null ) |
|
static |
Encrypts data using the server's key.
Note there is a special case - the empty string is not encrypted.
- Parameters
-
string | $data | Data to encrypt, or empty string for no data |
string | null | $method | Encryption method (only if you want to use a non-default method) |
- Return values
-
string | Encrypted data, or empty string for no data |
- Exceptions
-
◆ get_encryption_method()
static core\encryption::get_encryption_method |
( |
| ) |
|
|
staticprotected |
Gets the encryption method to use.
- Return values
-
string | Current encryption method |
◆ get_iv_length()
static core\encryption::get_iv_length |
( |
string | $method | ) |
|
|
staticprotected |
Gets the length in bytes of the initial values data required.
Note we currently retain support for all methods, in order to decrypt legacy {
- See also
- METHOD_OPENSSL} content
- Parameters
-
string | $method | Crypto method |
- Return values
-
◆ get_key()
static core\encryption::get_key |
( |
?string | $method = null | ) |
|
|
staticprotected |
Gets the current key, automatically creating it if there isn't one yet.
- Parameters
-
string | null | $method | Encryption method (only if you want to get a non-default key) |
- Return values
-
- Exceptions
-
◆ get_key_file()
static core\encryption::get_key_file |
( |
?string | $method = null | ) |
|
|
static |
Gets the file path used to store the secret key.
The filename contains the cipher method, so that if necessary to transition in future it would be possible to have multiple.
- Parameters
-
string | null | $method | Encryption method (only if you want to get a non-default key) |
- Return values
-
◆ get_key_folder()
static core\encryption::get_key_folder |
( |
| ) |
|
|
staticprotected |
Gets the folder used to store the secret key.
- Return values
-
◆ is_sodium_installed()
static core\encryption::is_sodium_installed |
( |
| ) |
|
|
static |
Checks if Sodium is installed.
- Return values
-
bool | True if the Sodium extension is available |
- Deprecated
- since Moodle 4.3 Sodium is always present
◆ key_exists()
static core\encryption::key_exists |
( |
?string | $method = null | ) |
|
|
static |
Checks if there is a key file.
- Parameters
-
string | null | $method | Encryption method (only if you want to check a non-default key) |
- Return values
-
bool | True if there is a key file |
◆ METHOD_OPENSSL
string const core\encryption::METHOD_OPENSSL = 'openssl-aes-256-ctr' |
Encryption method: hand-coded OpenSSL (less safe)
- Deprecated
◆ OPENSSL_CIPHER
string const core\encryption::OPENSSL_CIPHER = 'AES-256-CTR' |
The documentation for this class was generated from the following file:
- lib/classes/encryption.php