can someone tell me why fo base64 result give different result for PHP
with Javascript that's give right result
decimal 68 98 7 will show RGIH https://v2.cryptii.com/decimal/base64 javascript decimal to base64
why on php i not see same result
with this code
$x = floatval('68 98 7'); echo base64_encode($x);
will show Njg=
Thanks
This is because the website you've posted doesn't interpret the decimals as decimals, but as the decimal values for their ASCII counterparts. If you want to perform the same operation in PHP, you could first transform the decimal string to an array by exploding on the spaces, applying chr to each entry of the array, and then base64 encoding the imploded array:
$decimals = '68 98 7';
$chars = array_map(fn($decimal) => chr((int)$decimal), explode(' ',$decimals));
echo base64_encode(implode('', $chars));