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 }
[李景山php]每天laravel-20160827|McryptEncrypter-1
原创
©著作权归作者所有:来自51CTO博客作者lijingsan1的原创作品,请联系作者获取转载授权,否则将追究法律责任
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章