ParagonIE_Sodium_Core_Util::load_4() – Load a 4 character substring into an integer

You appear to be a bot. Output may be restricted

Description

Load a 4 character substring into an integer

Usage

$int = ParagonIE_Sodium_Core_Util::load_4( $string );

Parameters

$string
( string ) required

Returns

int

Source

File name: wordpress/wp-includes/sodium_compat/src/Core/Util.php


Lines:

1 to 19 of 19
    public static function load_4($string)
    {
        /* Type checks: */
        if (!is_string($string)) {
            throw new TypeError('Argument 1 must be a string, ' . gettype($string) . ' given.');
        }

        /* Input validation: */
        if (self::strlen($string) < 4) {
            throw new RangeException(
                'String must be 4 bytes or more; ' . self::ParagonIE_Sodium_Core_Util::strlen($string) . ' given.'
            );
        }
        
/** @var array<int, int> $unpacked */
        $unpacked = unpack('V', $string);
        return (int) $unpacked[1];
    }
 

 View on GitHub View on Trac