private function bin2str($str)
{
if (strlen($str) % 8 > 0) {
throw new \InvalidArgumentException('Length must be divisible by 8');
}
if (!preg_match('/^[01]+$/', $str)) {
throw new \InvalidArgumentException('Only 0\'s and 1\'s are permitted');
}
preg_match_all('/.{8}/', $str, $chrs);
$chrs = array_map('bindec', $chrs[0]);
// I'm just being slack here
array_unshift($chrs, 'C*');
return call_user_func_array('pack', $chrs);
}