Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

97
Views
PHP Decimal to base64 give different result with javascript

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

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

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));
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!