You are here

public static function ParagonIE_Sodium_Compat::increment in Automatic Updates 7

Same name and namespace in other branches
  1. 8 vendor/paragonie/sodium_compat/src/Compat.php \ParagonIE_Sodium_Compat::increment()

Increase a string (little endian)

@psalm-suppress MixedArgument

Parameters

string $var:

Return value

void

Throws

SodiumException

TypeError

1 call to ParagonIE_Sodium_Compat::increment()
php72compat.php in vendor/paragonie/sodium_compat/lib/php72compat.php

File

vendor/paragonie/sodium_compat/src/Compat.php, line 3089

Class

ParagonIE_Sodium_Compat

Code

public static function increment(&$var) {

  /* Type checks: */
  ParagonIE_Sodium_Core_Util::declareScalarType($var, 'string', 1);
  if (self::useNewSodiumAPI()) {
    sodium_increment($var);
    return;
  }
  if (self::use_fallback('increment')) {
    $func = '\\Sodium\\increment';
    $func($var);
    return;
  }
  $len = ParagonIE_Sodium_Core_Util::strlen($var);
  $c = 1;
  $copy = '';
  for ($i = 0; $i < $len; ++$i) {
    $c += ParagonIE_Sodium_Core_Util::chrToInt(ParagonIE_Sodium_Core_Util::substr($var, $i, 1));
    $copy .= ParagonIE_Sodium_Core_Util::intToChr($c);
    $c >>= 8;
  }
  $var = $copy;
}