It serves no real purpose. Guessing the SHA-256 hash is impossible due to entropy and if you *know* the hash then you pretty much know the file contents too.
There is no imaginable scenario where leaking the hash would not also leak the secret.
VarcharDatabaseTableColumn::create('fileExtension')
->length(10)
->notNull(),
- CharDatabaseTableColumn::create('secret')
- ->length(32)
- ->notNull(),
IntDatabaseTableColumn::create('objectTypeID'),
NotNullVarchar255DatabaseTableColumn::create('mimeType'),
IntDatabaseTableColumn::create('width'),
* @property-read int $fileSize
* @property-read string $fileHash
* @property-read string $fileExtension
- * @property-read string $secret
* @property-read int|null $objectTypeID
* @property-read string $mimeType
* @property-read int|null $width
public function getSourceFilename(): string
{
return \sprintf(
- '%d-%s-%s.%s',
+ '%d-%s.%s',
$this->fileID,
$this->fileHash,
- $this->secret,
$this->fileExtension,
);
}
'fileSize' => $fileTemporary->fileSize,
'fileHash' => $fileTemporary->fileHash,
'fileExtension' => File::getSafeFileExtension($mimeType, $fileTemporary->filename),
- 'secret' => \bin2hex(\random_bytes(16)),
'objectTypeID' => $fileTemporary->objectTypeID,
'mimeType' => $mimeType,
'width' => $width,
'fileSize' => \filesize($pathname),
'fileHash' => \hash_file('sha256', $pathname),
'fileExtension' => File::getSafeFileExtension($mimeType, $originalFilename),
- 'secret' => \bin2hex(\random_bytes(16)),
'objectTypeID' => $objectType->objectTypeID,
'mimeType' => $mimeType,
'width' => $width,
'fileSize' => $oldFile->fileSize,
'fileHash' => $oldFile->fileHash,
'fileExtension' => $oldFile->fileExtension,
- 'secret' => \hex2bin(\random_bytes(10)),
'objectTypeID' => $objectTypeObj->objectTypeID,
'mimeType' => $oldFile->mimeType,
'width' => $oldFile->width,
fileSize BIGINT NOT NULL,
fileHash CHAR(64) NOT NULL,
fileExtension VARCHAR(10) NOT NULL,
- secret CHAR(32) NOT NULL,
objectTypeID INT,
mimeType VARCHAR(255) NOT NULL,
width INT,