3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = hash('sha256', 'https://laundrapp.com'); $outstring = ''; $l = strlen($data); for ($i = 0; $i < $l; $i += 8) { $chunk = substr($data, $i, 8); $outlen = ceil((strlen($chunk) * 8)/6); //8bit/char in, 6bits/char out, round up $x = bin2hex($chunk); //gmp won't convert from binary, so go via hex $w = gmp_strval(gmp_init(ltrim($x, '0'), 16), 62); //gmp doesn't like leading 0s $pad = str_pad($w, $outlen, '0', STR_PAD_LEFT); $outstring .= $pad; } echo $outstring;
Output for 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.25, 7.4.27 - 7.4.32, 8.0.0 - 8.0.12, 8.0.14 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
4KHDOUFr25W4Z8z1zW70pV4OTOBhui6lu8m1pKdGO6128m5uXo6RujK4TwRCoypqTd4ObNMsn8oxL8WAAHForX8P
Output for 7.3.32 - 7.3.33, 7.4.26, 7.4.33, 8.0.13
Fatal error: Uncaught Error: Call to undefined function gmp_strval() in /in/eZT90:12 Stack trace: #0 {main} thrown in /in/eZT90 on line 12
Process exited with code 255.

preferences:
215.03 ms | 402 KiB | 287 Q