<?php
/**
 * @package   Essentials YOOtheme Pro 2.3.4 build 0217.0955
 * @author    ZOOlanders https://www.zoolanders.com
 * @copyright Copyright (C) Joolanders, SL
 * @license   http://www.gnu.org/licenses/gpl.html GNU/GPL
 */

namespace ZOOlanders\YOOessentials\Encryption;

class McryptLibrary extends Library
{
    public const MODE = MCRYPT_MODE_CBC;

    public const CIPHER = MCRYPT_RIJNDAEL_128;

    /**
     * @inheritdoc
     */
    public function encrypt($data, $key, $iv)
    {
        return mcrypt_encrypt(static::CIPHER, $key, $data, static::MODE, $iv);
    }

    /**
     * @inheritdoc
     */
    public function decrypt($data, $key, $iv)
    {
        return mcrypt_decrypt(static::CIPHER, $key, $data, static::MODE, $iv);
    }

    /**
     * @inheritdoc
     */
    public function generateIv()
    {
        return mcrypt_create_iv(mcrypt_get_iv_size(static::CIPHER, static::MODE), MCRYPT_DEV_URANDOM);
    }
}
