Binárny kód na text a naopak
Nasledujúce trieda v PHP dokáže preložiť binárny kód na ASCII (text) a naopak:
<?php class BinaryTranslator { public function toBinary($string) { $binary = ""; $space = " "; for ($i = 0; $i < mb_strlen($string); $i++) { if ($i == (mb_strlen($string) - 1)) $space = ""; $binary .= decbin(ord(mb_strtolower($string[$i]))) . $space; } return $binary; } public function fromBinary($binary) { $bin_arr = explode(" ", $binary); $string = ""; foreach ($bin_arr as $bin) $string .= chr(bindec((int)$bin)); return $string; } }