Crypto¶
-
class
OC\Security\Crypto¶ - Class Crypto provides a high-level encryption layer using AES-CBC. If no key has been providedit will use the secret defined in config.php as key. Additionally the message will be HMAC’d.Usage:$encryptWithDefaultPassword = \OC::$server->getCrypto()->encrypt(‘EncryptedText’);$encryptWithCustompassword = \OC::$server->getCrypto()->encrypt(‘EncryptedText’, ‘password’);
Source: lib/private/Security/Crypto.php#49 Implements: OCP\Security\ICrypto
Properties¶
Methods¶
-
public
OC\Security\Crypto::__construct($config)¶ Source: Parameters: - $config (
OCP\IConfig)
- $config (
-
public
OC\Security\Crypto::calculateHMAC($message, $password="")¶ Source: Parameters: - $message (string) The message to authenticate
- $password (string) Password to use (defaults to secret in config.php)
Returns: string Calculated HMAC
-
public
OC\Security\Crypto::encrypt($plaintext, $password="")¶ - Encrypts a value and adds an HMAC (Encrypt-Then-MAC)
Source: Parameters: - $plaintext (string)
- $password (string) Password to encrypt, if not specified the secret from config.php will be taken
Returns: string Authenticated ciphertext
-
public
OC\Security\Crypto::decrypt($authenticatedCiphertext, $password="")¶ - Decrypts a value and verifies the HMAC (Encrypt-Then-Mac)
Source: Parameters: - $authenticatedCiphertext (string)
- $password (string) Password to encrypt, if not specified the secret from config.php will be taken
Returns: string plaintext
Throws: \ExceptionIf the HMAC does not matchThrows: \ExceptionIf the decryption failedThrows: \ExceptionIf the HMAC does not matchThrows: \ExceptionIf the decryption failed