namespace Illuminate\Encryption;

use Exception;
use RuntimeException;
use Illuminate\Contracts\Encryption\DecryptException;
use Illuminate\Contracts\Encryption\EncryptException;
use Illuminate\Contracts\Encryption\Encrypter as EncrypterContract;

/**
* @deprecated since version 5.1. Use Illuminate\Encryption\Encrypter.
*/
class McryptEncrypter extends BaseEncrypter implements EncrypterContract
{// use Mcrypt Encrypter extends baseEncrypter
/**
* The algorithm used for encryption.
*
* @var string
*/
protected $cipher;// this is a algorithm used for encryption

/**
* The block size of the cipher.
*
* @var int
*/
protected $block;// block size about cipher

/**
* Create a new encrypter instance.
*
* @param string $key
* @param string $cipher
* @return void
*
* @throws \RuntimeException
*/
public function __construct($key, $cipher = MCRYPT_RIJNDAEL_128)
{
$key = (string) $key;// use parameter is key and cipher [algorithm]

if (static::supported($key, $cipher)) {
$this->key = $key;// key
$this->cipher = $cipher;// cipher
$this->block = mcrypt_get_iv_size($this->cipher, MCRYPT_MODE_CBC);// get the block
} else {
throw new RuntimeException('The only supported ciphers are MCRYPT_RIJNDAEL_128 and MCRYPT_RIJNDAEL_256.');
}// if wrong throw error
}