mirror of
https://github.com/Karaka-Management/oms-Media.git
synced 2026-02-16 17:28:41 +00:00
draft encrpytion
This commit is contained in:
parent
7525580ca9
commit
a429af8002
|
|
@ -52,6 +52,12 @@
|
||||||
"type": "TINYINT",
|
"type": "TINYINT",
|
||||||
"null": false
|
"null": false
|
||||||
},
|
},
|
||||||
|
"media_encryptionhash": {
|
||||||
|
"name": "media_encryptionhash",
|
||||||
|
"type": "VARCHAR(255)",
|
||||||
|
"null": true,
|
||||||
|
"default": null
|
||||||
|
},
|
||||||
"media_extension": {
|
"media_extension": {
|
||||||
"name": "media_extension",
|
"name": "media_extension",
|
||||||
"type": "VARCHAR(50)",
|
"type": "VARCHAR(50)",
|
||||||
|
|
|
||||||
|
|
@ -112,7 +112,22 @@ class Media implements \JsonSerializable
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
protected string $description = '';
|
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.
|
* Constructor.
|
||||||
|
|
@ -134,6 +149,58 @@ class Media implements \JsonSerializable
|
||||||
return $this->id;
|
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
|
* @return bool
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,7 @@ class MediaMapper extends DataMapperAbstract
|
||||||
'media_file' => ['name' => 'media_file', 'type' => 'string', 'internal' => 'path', 'autocomplete' => true],
|
'media_file' => ['name' => 'media_file', 'type' => 'string', 'internal' => 'path', 'autocomplete' => true],
|
||||||
'media_virtual' => ['name' => 'media_virtual', 'type' => 'string', 'internal' => 'virtualPath', 'autocomplete' => true],
|
'media_virtual' => ['name' => 'media_virtual', 'type' => 'string', 'internal' => 'virtualPath', 'autocomplete' => true],
|
||||||
'media_absolute' => ['name' => 'media_absolute', 'type' => 'bool', 'internal' => 'isAbsolute'],
|
'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_extension' => ['name' => 'media_extension', 'type' => 'string', 'internal' => 'extension'],
|
||||||
'media_size' => ['name' => 'media_size', 'type' => 'int', 'internal' => 'size'],
|
'media_size' => ['name' => 'media_size', 'type' => 'int', 'internal' => 'size'],
|
||||||
'media_created_by' => ['name' => 'media_created_by', 'type' => 'int', 'internal' => 'createdBy'],
|
'media_created_by' => ['name' => 'media_created_by', 'type' => 'int', 'internal' => 'createdBy'],
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user