diff --git a/config/settings.php b/config/settings.php index 59fda16..686df5a 100644 --- a/config/settings.php +++ b/config/settings.php @@ -145,6 +145,7 @@ | Supported: | - \Rawilk\Settings\Support\KeyGenerators\ReadableKeyGenerator | - \Rawilk\Settings\Support\KeyGenerators\Md5KeyGenerator (default) + | - \Rawilk\Settings\Support\KeyGenerators\HashKeyGenerator | */ 'key_generator' => \Rawilk\Settings\Support\KeyGenerators\Md5KeyGenerator::class, @@ -194,4 +195,14 @@ \Carbon\CarbonImmutable::class, \Illuminate\Support\Carbon::class, ], + + /* + |-------------------------------------------------------------------------- + | Hash Algorithm + |-------------------------------------------------------------------------- + | + | The hashing algorithm to use for the HashKeyGenerator. + | + */ + 'hash_algorithm' => 'xxh128', ]; diff --git a/src/Support/KeyGenerators/HashKeyGenerator.php b/src/Support/KeyGenerators/HashKeyGenerator.php new file mode 100644 index 0000000..815ba89 --- /dev/null +++ b/src/Support/KeyGenerators/HashKeyGenerator.php @@ -0,0 +1,40 @@ +serializer->serialize($context), + ); + } + + public function removeContextFromKey(string $key): string + { + throw new RuntimeException('HashKeyGenerator does not support removing the context from the key.'); + } + + public function setContextSerializer(ContextSerializer $serializer): static + { + $this->serializer = $serializer; + + return $this; + } + + public function contextPrefix(): string + { + throw new RuntimeException('HashKeyGenerator does not support a context prefix.'); + } +}