/*********************************************************************** * txtconv v 1,0 2006-jul-02 * * * * Copyright 2006 - Javier Smaldone (http://www.smaldone.com.ar) * * * * Distributed under the GNU/GPL license * * (see http://www.gnu.org/copyleft/gpl.html * * * * Text - Binary - Rot13 converter * * Based on binary.php - v 1.23 by snarkles (webgeek@snarkles.net) * ************************************************************************/ $version = "1.0"; function ttob($str) { $text_array = explode("\r\n", chunk_split($str, 1)); for ($n = 0; $n < count($text_array) - 1; $n++) { $result .= substr("0000".base_convert(ord($text_array[$n]), 10, 2), -8); } return chunk_split($result, 8, " "); } function btot($str) { $str = str_replace("\r\n", "", str_replace(" ", "", $str)); $text_array = explode("\r\n", chunk_split($str, 8)); for ($n = 0; $n < count($text_array) - 1; $n++) { $result .= chr(base_convert($text_array[$n], 2, 10)); } return htmlspecialchars($result); } // Get POST params $text = $_POST['text']; $action = $_POST['action']; if ($text) { // Clean up data $text = urldecode(stripslashes($text)); // Process the form switch ($action) { case "ttob": // Convert from text to binary $text = ttob($text); break; case "btot": // Convert from binary to text $text = btot($text); break; case "rot13": // Apply ROT13 $text = str_rot13($text); break; } } ?>