ParagonIE_Sodium_Core_Util::chrToInt

Advertisement

Summery Summery

Cache-timing-safe variant of ord()

Syntax Syntax

ParagonIE_Sodium_Core_Util::chrToInt( string $chr )

Parameters Parameters

$chr

(Required)

Return Return

(int)

Source Source

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

    public static function chrToInt($chr)
    {
        /* Type checks: */
        if (!is_string($chr)) {
            throw new TypeError('Argument 1 must be a string, ' . gettype($chr) . ' given.');
        }
        if (self::strlen($chr) !== 1) {
            throw new SodiumException('chrToInt() expects a string that is exactly 1 character long');
        }
        /** @var array<int, int> $chunk */
        $chunk = unpack('C', $chr);
        return (int) ($chunk[1]);
    }

Advertisement

Advertisement

Leave a Reply