You are here

public static function ParagonIE_Sodium_Core_Util::load_4 in Automatic Updates 8

Same name and namespace in other branches
  1. 7 vendor/paragonie/sodium_compat/src/Core/Util.php \ParagonIE_Sodium_Core_Util::load_4()

Load a 4 character substring into an integer

@internal You should not use this directly from another application

Parameters

string $string:

Return value

int

Throws

RangeException

TypeError

17 calls to ParagonIE_Sodium_Core_Util::load_4()
ParagonIE_Sodium_Core32_Curve25519::fe_frombytes in vendor/paragonie/sodium_compat/src/Core32/Curve25519.php
Give: 32-byte string. Receive: A field element object to use for internal calculations.
ParagonIE_Sodium_Core32_Curve25519::sc_muladd in vendor/paragonie/sodium_compat/src/Core32/Curve25519.php
Calculates (ab + c) mod l where l = 2^252 + 27742317777372353535851937790883648493
ParagonIE_Sodium_Core32_Curve25519::sc_reduce in vendor/paragonie/sodium_compat/src/Core32/Curve25519.php
@internal You should not use this directly from another application
ParagonIE_Sodium_Core_BLAKE2b::stringToContext in vendor/paragonie/sodium_compat/src/Core/BLAKE2b.php
Creates an SplFixedArray containing other SplFixedArray elements, from a string (compatible with \Sodium\crypto_generichash_{init, update, final})
ParagonIE_Sodium_Core_ChaCha20::encryptBytes in vendor/paragonie/sodium_compat/src/Core/ChaCha20.php
@internal You should not use this directly from another application

... See full list

File

vendor/paragonie/sodium_compat/src/Core/Util.php, line 430

Class

ParagonIE_Sodium_Core_Util
Class ParagonIE_Sodium_Core_Util

Code

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);
}