framework/base/Security.php
public function encryptByKey($data, $inputKey, $info = null)
    {
        return $this->encrypt($data, false, $inputKey, $info);
    }
public function encryptByKey($data, $inputKey, $info = null)
    {
        return $this->encrypt($data, false, $inputKey, $info);
    }
Encrypts data using a cryptographic key.
Derives keys for encryption and authentication from the input key using HKDF and a random salt,
which is very fast relative to [[encryptByPassword()]]. The input key must be properly
random -- use [[generateRandomKey()]] to generate keys.
The encrypted data includes a keyed message authentication code (MAC) so there is no need
to hash input or output data.
@param string $data the data to encrypt
@param string $inputKey the input to use for encryption and authentication
@param string $info optional context and application specific information, see [[hkdf()]]
@return string the encrypted data
@see decryptByKey()
@see encryptByPassword()