You are here

public static function ParagonIE_Sodium_Core32_Int32::fromReverseString in Automatic Updates 7

Same name and namespace in other branches
  1. 8 vendor/paragonie/sodium_compat/src/Core32/Int32.php \ParagonIE_Sodium_Core32_Int32::fromReverseString()

Parameters

string $string:

Return value

self

Throws

SodiumException

TypeError

6 calls to ParagonIE_Sodium_Core32_Int32::fromReverseString()
ParagonIE_Sodium_Core32_ChaCha20::encryptBytes in vendor/paragonie/sodium_compat/src/Core32/ChaCha20.php
@internal You should not use this directly from another application
ParagonIE_Sodium_Core32_ChaCha20_Ctx::__construct in vendor/paragonie/sodium_compat/src/Core32/ChaCha20/Ctx.php
ParagonIE_Sodium_Core_ChaCha20_Ctx constructor.
ParagonIE_Sodium_Core32_ChaCha20_IetfCtx::__construct in vendor/paragonie/sodium_compat/src/Core32/ChaCha20/IetfCtx.php
ParagonIE_Sodium_Core_ChaCha20_IetfCtx constructor.
ParagonIE_Sodium_Core32_HChaCha20::hChaCha20 in vendor/paragonie/sodium_compat/src/Core32/HChaCha20.php
ParagonIE_Sodium_Core32_HSalsa20::hsalsa20 in vendor/paragonie/sodium_compat/src/Core32/HSalsa20.php
Calculate an hsalsa20 hash of a single block

... See full list

File

vendor/paragonie/sodium_compat/src/Core32/Int32.php, line 763

Class

ParagonIE_Sodium_Core32_Int32
Class ParagonIE_Sodium_Core32_Int32

Code

public static function fromReverseString($string) {
  ParagonIE_Sodium_Core32_Util::declareScalarType($string, 'string', 1);
  $string = (string) $string;
  if (ParagonIE_Sodium_Core32_Util::strlen($string) !== 4) {
    throw new RangeException('String must be 4 bytes; ' . ParagonIE_Sodium_Core32_Util::strlen($string) . ' given.');
  }
  $return = new ParagonIE_Sodium_Core32_Int32();
  $return->limbs[0] = (int) ((ParagonIE_Sodium_Core32_Util::chrToInt($string[3]) & 0xff) << 8);
  $return->limbs[0] |= ParagonIE_Sodium_Core32_Util::chrToInt($string[2]) & 0xff;
  $return->limbs[1] = (int) ((ParagonIE_Sodium_Core32_Util::chrToInt($string[1]) & 0xff) << 8);
  $return->limbs[1] |= ParagonIE_Sodium_Core32_Util::chrToInt($string[0]) & 0xff;
  return $return;
}