$right ? 1 : 0; $left = $right; $one = $one << 1; } } imagedestroy($resized); return $bin; } public function hex($bin) { if (strlen($bin) !== self::SIZE * self::SIZE) { throw new Exception('Binary length must be ' . self::SIZE * self::SIZE); } $hex = ''; foreach (str_split($bin, 4) as $bin) { $hex .= dechex(bindec($bin)); } return $hex; } }