/** * Generate token basing on field names and custom key * * @param string|null $salt Encryption salt * * @return string * @throws \InvalidArgumentException */ public function tokenize($salt = null) { if ($salt === null) { $salt = $this->encrypter->randSalt(); } $value = implode('', array_keys($this->fields)); $token = $this->encrypter->crypt($value, $salt); return $token; }
/** * Generate authorization token * * @return string */ public function generateToken() { $token = $this->encrypter->setSalt($this->salt)->crypt($this->data['user']); return $token; }
/** * Generate hashed filename with same extension * * @param string $source Path * @param Encrypter $encrypter Encrypter * * @return File */ public function hashFile($source, Encrypter $encrypter = null) { if (!$source instanceof File) { $source = new File($source); } if ($encrypter === null) { $encrypter = new Encrypter(); } $hash = $encrypter->crypt($source->getAbsolutePath()); $path = $this->getPath(); $ext = $source->getExtension(); $target = new File($path . '/' . $hash . '.' . $ext); return $target; }