public static function ParagonIE_Sodium_Compat::add in Automatic Updates 7
Same name and namespace in other branches
- 8 vendor/paragonie/sodium_compat/src/Compat.php \ParagonIE_Sodium_Compat::add()
Add two numbers (little-endian unsigned), storing the value in the first parameter.
This mutates $val.
Parameters
string $val:
string $addv:
Return value
void
Throws
SodiumException
1 call to ParagonIE_Sodium_Compat::add()
- php72compat.php in vendor/
paragonie/ sodium_compat/ lib/ php72compat.php
File
- vendor/
paragonie/ sodium_compat/ src/ Compat.php, line 150
Class
Code
public static function add(&$val, $addv) {
$val_len = ParagonIE_Sodium_Core_Util::strlen($val);
$addv_len = ParagonIE_Sodium_Core_Util::strlen($addv);
if ($val_len !== $addv_len) {
throw new SodiumException('values must have the same length');
}
$A = ParagonIE_Sodium_Core_Util::stringToIntArray($val);
$B = ParagonIE_Sodium_Core_Util::stringToIntArray($addv);
$c = 0;
for ($i = 0; $i < $val_len; $i++) {
$c += $A[$i] + $B[$i];
$A[$i] = $c & 0xff;
$c >>= 8;
}
$val = ParagonIE_Sodium_Core_Util::intArrayToString($A);
}