src/Encryption/Service/CipherService.php
public function encrypt($data, string $key = null): string
    {
        $key = $this->createKey($key);
        $data = Crypto::encrypt(serialize($data), $key);

        return $data;
    }
public function encrypt($data, string $key = null): string
    {
        $key = $this->createKey($key);
        $data = Crypto::encrypt(serialize($data), $key);

        return $data;
    }
Encrypt data using secret key

@param mixed $data
@param string $key
@return string