ParagonIE_Sodium_Core_Util::load_4

Advertisement

Summery Summery

Load a 4 character substring into an integer

Syntax Syntax

ParagonIE_Sodium_Core_Util::load_4( string $string )

Parameters Parameters

$string

(string) (Required)

Return Return

(int)

Source Source

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

    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::strlen($string) . ' given.'
            );
        }
        /** @var array<int, int> $unpacked */
        $unpacked = unpack('V', $string);
        return (int) ($unpacked[1] & 0xffffffff);
    }

Advertisement

Advertisement

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.