mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-09-02 05:10:59 +00:00
feat: add secure module marketplace runtime (#745)
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Support\Module;
|
||||
|
||||
class ModuleAssetVersion
|
||||
{
|
||||
public const HASH_LENGTH = 12;
|
||||
|
||||
public static function forPath(string $path): ?string
|
||||
{
|
||||
$hash = is_file($path) ? hash_file('sha256', $path) : false;
|
||||
|
||||
return is_string($hash) ? substr($hash, 0, self::HASH_LENGTH) : null;
|
||||
}
|
||||
|
||||
public static function forContents(string $contents): string
|
||||
{
|
||||
return substr(hash('sha256', $contents), 0, self::HASH_LENGTH);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user