public function encrypt($data, $key) {
      $this->validateData($data);
      $this->validateKey($key);

      $iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length(self::CIPHER_METHOD));

      $encrypted = openssl_encrypt($data, self::CIPHER_METHOD, $key, 0, $iv);
      $encoded = base64_encode($encrypted . self::ENCRYPTED_IV_SEPERATOR . $iv);

      return new Encrypted($encoded);
    }