@ 2014-08-13T23:01:27Z <?php
function pack_encode($val) {
$str = '';
while ($val > 0) {
$str .= chr($val & 0xFF);
$val = $val >> 8;
}
// "/" json-encodes poorly and "=" is padding
return str_replace(
array('/', '='),
array('_', ''),
base64_encode($str)
);
}
for ($i=0; $i<32; $i++) {
echo pack_encode(1<<$i) . "\n";
}
/*
$arr = array();
$packed = pack('N', 32767);
for ($i=0; $i<strlen($packed); $i++) {
$arr[$i] = ord($packed[$i]);
}
print_r($arr);
function pack_encode($val) {
$b64 = base64_encode(pack($format, $val));
return str_replace(array('/', '='), array('_', ''), $b64); // "/" json-encodes poorly and "=" is padding
}
function pack_decode($bin) {
$b64 = str_replace('_', '/', $bin); // un-padded
$data = unpack('C'.(length($bin)/2), base64_decode($b64, false));
$val = 0;
foreach ($data as $v) {
$val = ($val<<$width) | $v;
}
return $val;
}
$max = 32767;
$n = 20;
$step = intval($max/$n);
for ($i=0; $i<=$n; $i++) {
$val = $i*$step;
$enc = pack_encode($val);
$dec = pack_decode($val);
echo "$enc $dec $val\n";
}
*/
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 4.3.0 - 4.3.11 , 4.4.0 - 4.4.9 , 5.0.0 - 5.0.5 , 5.1.0 - 5.1.6 , 5.2.0 - 5.2.17 , 5.3.0 - 5.3.29 , 5.4.0 - 5.4.45 , 5.5.0 - 5.5.38 , 5.6.0 - 5.6.28 , 7.0.0 - 7.0.20 , 7.1.0 - 7.1.10 , 7.2.0 - 7.2.33 , 7.3.16 - 7.3.33 , 7.4.0 - 7.4.33 , 8.0.0 - 8.0.30 , 8.1.0 - 8.1.27 , 8.2.0 - 8.2.17 , 8.3.0 - 8.3.4 AQ
Ag
BA
CA
EA
IA
QA
gA
AAE
AAI
AAQ
AAg
ABA
ACA
AEA
AIA
AAAB
AAAC
AAAE
AAAI
AAAQ
AAAg
AABA
AACA
AAAAAQ
AAAAAg
AAAABA
AAAACA
AAAAEA
AAAAIA
AAAAQA
AAAAgA
preferences:dark mode live preview
272.83 ms | 406 KiB | 350 Q