public function __construct($file, Key $key = null)
{
if (is_string($file)) {
$this->fp = \fopen($file, 'rb');
$this->closeAfter = true;
$this->pos = 0;
$this->stat = \fstat($this->fp);
} elseif (is_resource($file)) {
$this->fp = $file;
$this->pos = \ftell($this->fp);
$this->stat = \fstat($this->fp);
} else {
throw new \ParagonIE\Halite\Alerts\InvalidType('Argument 1: Expected a filename or resource');
}
$this->hashKey = !empty($key) ? $key->getRawKeyMaterial() : '';
$this->hash = $this->getHash();
}