You are here

public static function ParagonIE_Sodium_Compat::hex2bin in Automatic Updates 8

Same name and namespace in other branches
  1. 7 vendor/paragonie/sodium_compat/src/Compat.php \ParagonIE_Sodium_Compat::hex2bin()

Cache-timing-safe implementation of hex2bin().

@psalm-suppress TooFewArguments @psalm-suppress MixedArgument

Parameters

string $string Hexadecimal string:

Return value

string Raw binary string

Throws

SodiumException

TypeError

2 calls to ParagonIE_Sodium_Compat::hex2bin()
php72compat.php in vendor/paragonie/sodium_compat/lib/php72compat.php
sodium_compat.php in vendor/paragonie/sodium_compat/lib/sodium_compat.php

File

vendor/paragonie/sodium_compat/src/Compat.php, line 3063

Class

ParagonIE_Sodium_Compat

Code

public static function hex2bin($string) {

  /* Type checks: */
  ParagonIE_Sodium_Core_Util::declareScalarType($string, 'string', 1);
  if (self::useNewSodiumAPI()) {
    if (is_callable('sodium_hex2bin')) {
      return (string) sodium_hex2bin($string);
    }
  }
  if (self::use_fallback('hex2bin')) {
    return (string) call_user_func('\\Sodium\\hex2bin', $string);
  }
  return ParagonIE_Sodium_Core_Util::hex2bin($string);
}