sodium_add

(PHP 7 >= 7.2.0, PHP 8)

sodium_addAdd large numbers

说明

function sodium_add(string &$string1, string $string2): void

This adds the parameter string2 to string1, overwriting the value stored in string1. This function assumes both parameters are binary strings that represent unsigned integers in little-endian byte order.

参数

string1
String representing an arbitrary-length unsigned integer in little-endian byte order. This parameter is passed by reference and will hold the sum of the two parameters.
string2
String representing an arbitrary-length unsigned integer in little-endian byte order.

返回值

没有返回值。

添加备注

用户贡献的备注 1 note

up
0
Anonymous
19 days ago
<?php

$a = "\x01\x00\x00\x00"; // 1 (32-bit little-endian)
$b = "\x02\x00\x00\x00"; // 2 (32-bit little-endian)

echo "Before: " . bin2hex($a) . PHP_EOL;

sodium_add($a, $b);

echo "After:  " . bin2hex($a) . PHP_EOL;

?>

Output:

Before: 01000000
After:  03000000
To Top