You are here

public static function ParagonIE_Sodium_Core_Util::store_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::store_3()

Store a 24-bit integer into a string, treating it as big-endian.

@internal You should not use this directly from another application

Parameters

int $int:

Return value

string

Throws

TypeError

File

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

Class

ParagonIE_Sodium_Core_Util
Class ParagonIE_Sodium_Core_Util

Code

public static function store_3($int) {

  /* Type checks: */
  if (!is_int($int)) {
    if (is_numeric($int)) {
      $int = (int) $int;
    }
    else {
      throw new TypeError('Argument 1 must be an integer, ' . gettype($int) . ' given.');
    }
  }

  /** @var string $packed */
  $packed = pack('N', $int);
  return self::substr($packed, 1, 3);
}