public function encrypt($key, $data, $mode, $initialization_vector)
    {
        if (isset(self::$cipher_mode_map[$mode])) {
            $mode = self::$cipher_mode_map[$mode];
        } else {
            throw new InvalidArgumentException('Unknown cipher mode "'. $mode .'"');
        }

        $key = $this->processKey($key);

        $encrypted = mcrypt_encrypt(MCRYPT_DES, $key, $data, $mode, $initialization_vector);

        if (false === $encrypted) {
            throw CryptographicFailureException::forReasonCode(
                CryptographicFailureException::CODE_FOR_ENCRYPTION_FAILURE
            );
        }

        return $encrypted;
    }
public function encrypt($key, $data, $mode, $initialization_vector)
    {
        if (isset(self::$cipher_mode_map[$mode])) {
            $mode = self::$cipher_mode_map[$mode];
        } else {
            throw new InvalidArgumentException('Unknown cipher mode "'. $mode .'"');
        }

        $key = $this->processKey($key);

        $encrypted = mcrypt_encrypt(MCRYPT_DES, $key, $data, $mode, $initialization_vector);

        if (false === $encrypted) {
            throw CryptographicFailureException::forReasonCode(
                CryptographicFailureException::CODE_FOR_ENCRYPTION_FAILURE
            );
        }

        return $encrypted;
    }
{@inheritDoc}