|
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 () |
|
static | key_exists (?string $method=null) |
| Checks if there is a key file.
|
|
|
string const | METHOD_SODIUM = 'sodium' |
| Encryption method: Sodium.
|
|
|
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.
- 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
-
moodle_exception | If the server already has a key, or there is an error |
◆ decrypt()
static core\encryption::decrypt |
( |
string | $data | ) |
|
|
static |
Decrypts data using the server's key.
The decryption works with either supported method.
- 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
-
moodle_exception | If the key doesn't exist, or the string is too long |
◆ 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.
- 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
-
moodle_exception | If there isn't one already (and creation is disabled) |
◆ 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 |
◆ 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 |
The documentation for this class was generated from the following file:
- lib/classes/encryption.php