Pad and use mcrypt on the given value and input vector.

@param  string  $value
@param  string  $iv
@return string
13572
protected function padAndMcrypt($value, $iv)
    {
        $value = $this->addPadding(serialize($value));

        return mcrypt_encrypt($this->cipher, $this->key, $value, MCRYPT_MODE_CBC, $iv);
    }
1198689
public function pad($size, $value)
    {
        try {
            $arr = array_pad($this->val(), $size, $value);
        } catch (\ErrorException $e) {
            throw new ArrayObjectException($e->getMessage());
        }

        $this->val($arr);

        return $this;
    }
908521
public function encrypt($data, $key = null, $iv = null)
    {
        // @see https://github.com/ventoviro/windwalker-crypt/issues/2
        throw new \LogicException(
            'Sorry, due to the secure issue, McryptCipher is nolonger supported, you can only decrypt data now.'
        );

        return;

        $iv = $iv ?: $this->getIVKey();

        $key = CryptHelper::repeatToLength($key, 24, true);

        // Encrypt the data.
        $encrypted = mcrypt_encrypt($this->type, $key, $data, $this->mode, $iv);

        return base64_encode($iv . $encrypted);
    }
1174969
public function encode($value)
    {
        $encryptedValue = $this->getEncryptor()->encrypt($value);
        $encodedValue = base64_encode($encryptedValue);

        return $encodedValue;
    }
472027
public function keyOf($value)
    {
        foreach ($this->items as $key => $iValue) {
            if ($value === $iValue) {
                return $key;
            }
        }

        return null;
    }
936645
public static function decode($value, $key = false)
	{
		$key ? static::$crypter->setKey($key) : static::$crypter->setKey(static::safe_b64decode(static::$config['crypto_key']));
		static::$crypter->setIV(static::safe_b64decode(static::$config['crypto_iv']));

		$value = static::safe_b64decode($value);
		if ($value = static::validate_hmac($value))
		{
			return static::$crypter->decrypt($value);
		}
		else
		{
			return false;
		}
	}
1090795
public function encrypt($string, $key = null, $iv = null)
    {
        $key = $key ?: $this->getKey();
        $iv = $iv ?: $this->getIv();

        return $this->cipher->encrypt($string, $key, $iv);
    }
1176959
public function decryptBinary(string $value, string $key): string
    {
        $iv = substr($value, 0, $this->ivLength);
        $encrypted = substr($value, $this->ivLength);
        $key = $this->hashKey($key);
        $opts = OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING;
        $ret = openssl_decrypt($encrypted, $this->cipher, $key, $opts, $iv);
        if ($ret === false) {
            throw new \Exception("decryption failed; ".openssl_error_string());
        }
        return $ret;
    }
1207898
protected function mcryptDecrypt($value, $iv)
    {
        try {
            return mcrypt_decrypt($this->cipher, $this->key, $value, MCRYPT_MODE_CBC, $iv);
        } catch (Exception $e) {
            throw new DecryptException($e->getMessage());
        }
    }
550969
public function encrypt($value)
    {
        // compress prior to encryption
        if (!empty($this->compression)) {
            $compress = new Compress($this->compression);
            $value    = $compress($value);
        }

        try {
            $encrypted = $this->blockCipher->encrypt($value);
        } catch (CryptException\InvalidArgumentException $e) {
            throw new Exception\InvalidArgumentException($e->getMessage());
        }
        return $encrypted;
    }
1094985
public static function hash($value)
    {
        $typeIdentifier = gettype($value)[0];

        switch ($typeIdentifier) {

            case 's': //string

                return 's' . (strlen($value) > 32 ? md5($value) : $value);

            case 'i': //integer
            case 'b': //boolean
            case 'd': //double
            case 'r': //resource
            case 'u': //unknown type

                return $typeIdentifier . $value;

            case 'N': //NULL

                return 'N';

            case 'o': //object

                return 'o' . spl_object_hash($value);

            case 'a': //array

                return self::arrayHash($value);
        }
    }
944150
public byte[] encrypt(String iv, String message, Encoder encoder) {
        return encrypt(encoder.decode(iv), encoder.decode(message));
    }
757045
public function encrypt($value)
	{
		$iv = mcrypt_create_iv($this->getIvSize(), $this->getRandomizer());

		$value = base64_encode($this->padAndMcrypt($value, $iv));

		// Once we have the encrypted value we will go ahead base64_encode the input
		// vector and create the MAC for the encrypted value so we can verify its
		// authenticity. Then, we'll JSON encode the data in a "payload" array.
		$mac = $this->hash($iv = base64_encode($iv), $value);

		return base64_encode(json_encode(compact('iv', 'value', 'mac')));
	}
1019876
public function encode($value)
    {
        if ($value === '' || !is_scalar($value)) {
            return false;
        }

        $text = $value;
        $ivSize = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
        $iv = mcrypt_create_iv($ivSize, MCRYPT_RAND);
        $cryptText = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $this->secureKey, $text, MCRYPT_MODE_ECB, $iv);

        return trim($this->safeBase64Encode($cryptText));
    }
18538
protected function addPadding($value)
    {
        $pad = $this->block - (strlen($value) % $this->block);

        return $value.str_repeat(chr($pad), $pad);
    }
269334
protected function encryptMcrypt($input)
    {
        $ivlen = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC);
        $iv    = mcrypt_create_iv($ivlen, MCRYPT_RAND);
        $key   = $this->getEncryptionSaltKey();

        return $iv . mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $input, MCRYPT_MODE_CBC, $iv);
    }
263865
public function make($value, array $options = array())
    {
        $cost = isset($options['rounds']) ? $options['rounds'] : $this->rounds;

        $hash = password_hash($value, PASSWORD_DEFAULT, array('cost' => $cost));

        if ($hash === false) {
            throw new \RuntimeException("Bcrypt hashing not supported.");
        }

        return $hash;
    }