draft encrpytion

This commit is contained in:
Dennis Eichhorn 2019-10-05 20:10:54 +02:00
parent 7525580ca9
commit a429af8002
3 changed files with 75 additions and 1 deletions

View File

@ -52,6 +52,12 @@
"type": "TINYINT",
"null": false
},
"media_encryptionhash": {
"name": "media_encryptionhash",
"type": "VARCHAR(255)",
"null": true,
"default": null
},
"media_extension": {
"name": "media_extension",
"type": "VARCHAR(50)",

View File

@ -112,7 +112,22 @@ class Media implements \JsonSerializable
* @since 1.0.0
*/
protected string $description = '';
protected $descriptionRaw = '';
/**
* Media Description.
*
* @var string
* @since 1.0.0
*/
protected string $descriptionRaw = '';
/**
* Media encryption hash.
*
* @var null|string
* @since 1.0.0
*/
protected ?string $encryptionHash = null;
/**
* Constructor.
@ -134,6 +149,58 @@ class Media implements \JsonSerializable
return $this->id;
}
public function encrypt(string $password, string $outputPath) : void
{
// todo: implement;
}
public function decrypt(string $password, string $outputPath) : string
{
// todo: implement;
return '';
}
/**
* Set encryption hash
*
* @param null|string $encryptionHash Hash from encryption password
*
* @return void
*
* @since 1.0.0
*/
public function setEncryptionHash(?string $encryptionHash) : void
{
$this->encryptionHash = $encryptionHash;
}
/**
* Is media file encrypted?
*
* @return bool
*
* @since 1.0.0
*/
public function isEncrypted() : bool
{
return $this->encryptionHash !== null;
}
/**
* Compare hash with encryption hash of the media file
*
* @param string $hash User hash
*
* @return bool
*
* @since 1.0.0
*/
public function compareEncryptionHash(string $hash) : bool
{
return \hash_equals($this->encryptionHash, $hash);
}
/**
* @return bool
*

View File

@ -44,6 +44,7 @@ class MediaMapper extends DataMapperAbstract
'media_file' => ['name' => 'media_file', 'type' => 'string', 'internal' => 'path', 'autocomplete' => true],
'media_virtual' => ['name' => 'media_virtual', 'type' => 'string', 'internal' => 'virtualPath', 'autocomplete' => true],
'media_absolute' => ['name' => 'media_absolute', 'type' => 'bool', 'internal' => 'isAbsolute'],
'media_encryptionhash' => ['name' => 'media_encryptionhash', 'type' => 'string', 'internal' => 'encryptionHash'],
'media_extension' => ['name' => 'media_extension', 'type' => 'string', 'internal' => 'extension'],
'media_size' => ['name' => 'media_size', 'type' => 'int', 'internal' => 'size'],
'media_created_by' => ['name' => 'media_created_by', 'type' => 'int', 'internal' => 'createdBy'],