You are here

public static function ParagonIE_Sodium_Core_Util::load_3 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_3()

Load a 3 character substring into an integer

@internal You should not use this directly from another application

Parameters

string $string:

Return value

int

Throws

RangeException

TypeError

6 calls to ParagonIE_Sodium_Core_Util::load_3()
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_Curve25519::fe_frombytes in vendor/paragonie/sodium_compat/src/Core/Curve25519.php
Give: 32-byte string. Receive: A field element object to use for internal calculations.
ParagonIE_Sodium_Core_Curve25519::sc_muladd in vendor/paragonie/sodium_compat/src/Core/Curve25519.php
Calculates (ab + c) mod l where l = 2^252 + 27742317777372353535851937790883648493

... See full list

File

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

Class

ParagonIE_Sodium_Core_Util
Class ParagonIE_Sodium_Core_Util

Code

public static function load_3($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) < 3) {
    throw new RangeException('String must be 3 bytes or more; ' . self::strlen($string) . ' given.');
  }

  /** @var array<int, int> $unpacked */
  $unpacked = unpack('V', $string . "\0");
  return (int) ($unpacked[1] & 0xffffff);
}