You are here

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

Stores a 64-bit integer as an string, treating it as little-endian.

@internal You should not use this directly from another application

Parameters

int $int:

Return value

string

Throws

TypeError

11 calls to ParagonIE_Sodium_Core_Util::store64_le()
ParagonIE_Sodium_Compat::crypto_kdf_derive_from_key in vendor/paragonie/sodium_compat/src/Compat.php
ParagonIE_Sodium_Core_Salsa20::salsa20_xor_ic in vendor/paragonie/sodium_compat/src/Core/Salsa20.php
@internal You should not use this directly from another application
ParagonIE_Sodium_Crypto::aead_chacha20poly1305_decrypt in vendor/paragonie/sodium_compat/src/Crypto.php
AEAD Decryption with ChaCha20-Poly1305
ParagonIE_Sodium_Crypto::aead_chacha20poly1305_encrypt in vendor/paragonie/sodium_compat/src/Crypto.php
AEAD Encryption with ChaCha20-Poly1305
ParagonIE_Sodium_Crypto::aead_chacha20poly1305_ietf_decrypt in vendor/paragonie/sodium_compat/src/Crypto.php
AEAD Decryption with ChaCha20-Poly1305, IETF mode (96-bit nonce)

... See full list

File

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

Class

ParagonIE_Sodium_Core_Util
Class ParagonIE_Sodium_Core_Util

Code

public static function store64_le($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.');
    }
  }
  if (PHP_INT_SIZE === 8) {
    if (PHP_VERSION_ID >= 50603) {

      /** @var string $packed */
      $packed = pack('P', $int);
      return $packed;
    }
    return self::intToChr($int & 0xff) . self::intToChr($int >> 8 & 0xff) . self::intToChr($int >> 16 & 0xff) . self::intToChr($int >> 24 & 0xff) . self::intToChr($int >> 32 & 0xff) . self::intToChr($int >> 40 & 0xff) . self::intToChr($int >> 48 & 0xff) . self::intToChr($int >> 56 & 0xff);
  }
  if ($int > PHP_INT_MAX) {
    list($hiB, $int) = self::numericTo64BitInteger($int);
  }
  else {
    $hiB = 0;
  }
  return self::intToChr($int & 0xff) . self::intToChr($int >> 8 & 0xff) . self::intToChr($int >> 16 & 0xff) . self::intToChr($int >> 24 & 0xff) . self::intToChr($hiB & 0xff) . self::intToChr($hiB >> 8 & 0xff) . self::intToChr($hiB >> 16 & 0xff) . self::intToChr($hiB >> 24 & 0xff);
}