diff --git a/src/Base64.php b/src/Base64.php index cac557f..f9596ce 100644 --- a/src/Base64.php +++ b/src/Base64.php @@ -53,15 +53,15 @@ public static function encode( #[\SensitiveParameter] string $binString ): string { - if (extension_loaded('sodium')) { + if (\extension_loaded('sodium')) { $variant = match(static::class) { - Base64::class => SODIUM_BASE64_VARIANT_ORIGINAL, - Base64UrlSafe::class => SODIUM_BASE64_VARIANT_URLSAFE, + Base64::class => \SODIUM_BASE64_VARIANT_ORIGINAL, + Base64UrlSafe::class => \SODIUM_BASE64_VARIANT_URLSAFE, default => 0, }; if ($variant > 0) { try { - return sodium_bin2base64($binString, $variant); + return \sodium_bin2base64($binString, $variant); } catch (SodiumException $ex) { throw new RangeException($ex->getMessage(), $ex->getCode(), $ex); } @@ -85,15 +85,15 @@ public static function encodeUnpadded( #[\SensitiveParameter] string $src ): string { - if (extension_loaded('sodium')) { + if (\extension_loaded('sodium')) { $variant = match(static::class) { - Base64::class => SODIUM_BASE64_VARIANT_ORIGINAL_NO_PADDING, - Base64UrlSafe::class => SODIUM_BASE64_VARIANT_URLSAFE_NO_PADDING, + Base64::class => \SODIUM_BASE64_VARIANT_ORIGINAL_NO_PADDING, + Base64UrlSafe::class => \SODIUM_BASE64_VARIANT_URLSAFE_NO_PADDING, default => 0, }; if ($variant > 0) { try { - return sodium_bin2base64($src, $variant); + return \sodium_bin2base64($src, $variant); } catch (SodiumException $ex) { throw new RangeException($ex->getMessage(), $ex->getCode(), $ex); } @@ -199,15 +199,15 @@ public static function decode( 'Incorrect padding' ); } - if (extension_loaded('sodium')) { + if (\extension_loaded('sodium')) { $variant = match(static::class) { - Base64::class => SODIUM_BASE64_VARIANT_ORIGINAL_NO_PADDING, - Base64UrlSafe::class => SODIUM_BASE64_VARIANT_URLSAFE_NO_PADDING, + Base64::class => \SODIUM_BASE64_VARIANT_ORIGINAL_NO_PADDING, + Base64UrlSafe::class => \SODIUM_BASE64_VARIANT_URLSAFE_NO_PADDING, default => 0, }; if ($variant > 0) { try { - return sodium_base642bin($encodedString, $variant); + return \sodium_base642bin($encodedString, $variant); } catch (SodiumException $ex) { throw new RangeException($ex->getMessage(), $ex->getCode(), $ex); } diff --git a/src/Hex.php b/src/Hex.php index d4d5259..50f77d1 100644 --- a/src/Hex.php +++ b/src/Hex.php @@ -48,9 +48,9 @@ public static function encode( #[\SensitiveParameter] string $binString ): string { - if (extension_loaded('sodium')) { + if (\extension_loaded('sodium')) { try { - return sodium_bin2hex($binString); + return \sodium_bin2hex($binString); } catch (SodiumException $ex) { throw new RangeException($ex->getMessage(), $ex->getCode(), $ex); } @@ -117,9 +117,9 @@ public static function decode( string $encodedString, bool $strictPadding = false ): string { - if (extension_loaded('sodium') && $strictPadding) { + if (\extension_loaded('sodium') && $strictPadding) { try { - return sodium_hex2bin($encodedString); + return \sodium_hex2bin($encodedString); } catch (SodiumException $ex) { throw new RangeException($ex->getMessage(), $ex->getCode(), $ex); }