changeset 418:bc3737021c3c draft

translator
author sevil <sevil@sevilnatas.ano>
date Wed, 02 Mar 2011 09:34:43 -0600
parents a7da0e1504e4
children b88616ae75d8
files db/usr/sevilNatas/etc/translator.php
diffstat 1 files changed, 322 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/db/usr/sevilNatas/etc/translator.php	Wed Mar 02 09:34:43 2011 -0600
@@ -0,0 +1,322 @@
+<? 
+static $binary;
+static $ascii;
+static $hex;
+static $b64;
+static $char;
+
+?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
+<title>[sevilNatas@anoNet]:~# Translator</title>
+<link rel="stylesheet" type="text/css" href="../main.css" />
+<style>
+.ff{font-size: 10px;
+	font-family:verdana,arial,helvetica,sans;
+	color: #333333;
+	background: #eee;
+	}
+.btn{
+	font-size: 8px;
+	font-family:verdana,arial,helvetica,sans;
+	color: #333333;
+	background: #eee;
+	}
+BODY{
+scrollbar-3dlight-color:#999999;
+scrollbar-arrow-color:#999999;
+scrollbar-base-color:#DDDDDD;
+scrollbar-darkshadow-color:#999999;
+scrollbar-face-color:#DDDDDD;
+scrollbar-highlight-color:#DDDDDD;
+scrollbar-shadow-color:#DDDDDD;
+scrollbar-track-color:#CCCCCC;
+}
+
+</style>
+</head>
+<body>
+
+<!-- Begin Wrapper -->
+   <div id="wrapper">
+   <!-- Begin Header -->
+      <div id="header">
+         <h1>Translator, Binary</h1>		 
+      </div>
+   <!-- End Header -->
+   <!-- Begin Naviagtion -->
+      <div id="navigation">
+         <a href="../index.shtml" target="_top">Main</a> | 
+	 <a href="../pastebin/" target="_top">Pastebin</a> |
+         <a href="../translator/" target="_top">Translator</a> |
+         <a href="../library.html" target="_top">Library</a> |
+         <a href="../chat.html" target="_top">IRC</a>  |
+	 <a href="../math.html" target="_top">Mathematics</a> |
+         <a href="http://www.sevilwiki.ano/" target="_blank">
+            sevilWiki <img style="border:0px solid black;" src="../imgs/external.png" alt="(external link)" width="10" height="10" />
+         </a>
+      </div>
+      <!-- End Naviagtion -->
+      <!-- Begin Content -->
+         <div id="content">
+
+
+</head>
+<body bgcolor="#ffffff" text="#000">
+
+<div style="float: left; width: 90px;"><b>Please note:</b></div>
+<div style="float: left;"> This application encodes and decodes 
+<a href="http://en.wikipedia.org/wiki/ASCII">ASCII</a> and 
+<a href="http://en.wikipedia.org/wiki/ANSI">ANSI</a> 
+text.  <br />Only codepoints &lt; 128 are ASCII.</div>
+<div style="clear: both;"></div><br />
+
+
+<center>
+<table border=0 cellspacing=0 cellpadding=0><tr><td align=center>
+<font face="verdana,arial,helvetica" size=1>
+
+<table border=0 cellspacing=0 cellpadding=10>
+<tr><form method="POST"><td align=center valign=top>
+<font face="verdana,arial,helvetica" size=1>
+
+<b>[ <a href="../ascii/">TEXT</a> ]</b><br />
+<textarea cols=48 rows=15 wrap="virtual" name="ascii" class="ff"><?php
+
+set_magic_quotes_runtime(0);
+foreach($_POST as $key=>$val){ $$key = stripslashes($val); }
+
+#$_POST[ascii] = str_replace("\\'","'",$_POST[ascii]);
+#$_POST[ascii] = str_replace("\\\"","\"",$_POST[ascii]);
+#$_POST[ascii] = str_replace("\\\\","\\",$_POST[ascii]);
+if($ascii != "") print htmlentities($ascii);
+else {
+
+if($binary != "") {
+	$binary_ = preg_replace("/[^01]/","", $binary);
+	for($i = 0; $i < strlen($binary_); $i = $i + 8)
+	$ascii = $ascii.chr(bindec(substr($binary_, $i, 8)));
+}
+
+if($hex != "") {
+	$hex_ = preg_replace("/[^0-9a-fA-F]/","", $hex);
+	for($i = 0; $i < strlen($hex_); $i = $i + 2)
+	$ascii = $ascii.chr(hexdec(substr($hex_, $i, 2)));
+}
+
+if($b64 != "") {
+	//$ascii = gzinflate($gzip);
+	$ascii = base64_decode($b64);
+}
+
+if($char != "") {
+	$char_ = preg_split("/\\D+/",trim($char));
+	foreach ($char_ as $key)
+	$ascii = $ascii.chr($key);
+}
+
+echo htmlentities($ascii);
+}
+
+?></textarea>
+<br />
+<input type="submit" class="btn" value="&lt; ENCODE &gt;">
+</td></form><form method="POST"><td align=center valign=top>
+<font face="verdana,arial,helvetica" size=1>
+
+<b>2 [ <a href="http://en.wikipedia.org/wiki/Binary_numeral_system"><acronym title="Binary">BINARY</acronym></a> ]</b><br />
+<textarea cols=48 rows=15 wrap="virtual" name="binary" class="ff"><?php
+
+if($binary != "") echo $binary;
+else if($ascii != "") {
+$val = strval(decbin(ord(substr($ascii, 0, 1))));
+echo str_repeat("0", 8-strlen($val)).$val;
+for($i = 1; $i < strlen($ascii); $i = $i + 1) {
+$val = strval(decbin(ord(substr($ascii, $i, 1))));
+echo " ".str_repeat("0", 8-strlen($val)).$val;
+}
+}
+
+?></textarea>
+<br />
+<input type="submit" class="btn" value="&lt; DECODE &gt;">
+</td></form><form method="POST"><td align=center valign=top>
+<font face="verdana,arial,helvetica" size=1>
+
+<b>4 [ <a href="http://en.wikipedia.org/wiki/Hexidecimal"><acronym title="Hexidecimal">HEX</acronym></a> ]</b><br />
+<textarea cols=48 rows=15 wrap="virtual" name="hex" class="ff"><?php
+
+if($hex != "") echo $hex;
+else if($ascii != "") {
+$val = dechex(ord(substr($ascii, 0, 1)));
+echo str_repeat("0", 2-strlen($val)).$val;
+for($i = 1; $i < strlen($ascii); $i = $i + 1) {
+  $val = dechex(ord(substr($ascii, $i, 1)));
+  echo " ".str_repeat("0", 2-strlen($val)).$val;
+}
+}
+
+
+?></textarea>
+<br />
+<input type="submit" class="btn" value="&lt; DECODE &gt;">
+</td></tr></form><br />
+<?/*
+<!--OCT-->
+<form method="POST"><tr><td align=center valign=top>
+<font face="verdana,arial,helvetica" size=1>
+
+<b>3 [ OCT ]</b><br />
+<textarea cols=48 rows=15 wrap="virtual" name="oct" class="ff"><?php
+
+if($oct != "") echo $oct;
+else if($ascii != "") {
+	$val = 0;
+	for($i = 0; $i < strlen($ascii); $i = $i + 3) {
+		$val = ord(substr($ascii, $i, 1));
+		$val = $val * 256 + ord(substr($ascii, $i + 1, 1));
+		$val = $val * 256 + ord(substr($ascii, $i + 2, 1));
+		//echo "debug $val topbit = ".intval($val / 64 / 64 / 64)."\n";
+		printf("%08d",oct_decode($val));
+		$val = 0;
+	}
+	if($val > 0) echo oct_decode($val);
+}
+
+function b64_decode($val) {
+$tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+if($val >= 64) return oct_decode(intval($val / 64))."".substr($tab,$val%64,1);
+return substr($tab,$val,1);
+}
+function oct_decode($val) {
+if($val >= 8) return oct_decode(intval($val / 8))."".($val%8);
+return "".$val;
+}
+*/
+?></textarea>
+<br />
+<? //<input type="submit" class="btn" value="&lt; DECODE &gt;">?>
+</td></form>
+
+<!--BASE 64-->
+<form method="POST"><tr><td align=center valign=top>
+<font face="verdana,arial,helvetica" size=1>
+
+<b>6 [ <a href="http://en.wikipedia.org/wiki/Base64">BASE64</a> ]</b><br />
+<textarea cols=48 rows=15 wrap="virtual" name="b64" class="ff"><?php
+
+if($b64 != "") echo $b64;
+else if($ascii != "") {
+echo base64_encode($ascii);
+//$gzip = gzencode($ascii, 9);
+//echo substr($gzip,10,strlen($gzip)-19);
+}
+
+?></textarea>
+<br />
+<input type="submit" class="btn" value="&lt; DECODE &gt;">
+</td></form>
+
+<!--CHAR-->
+<form method="POST"><td align=center valign=top>
+<font face="verdana,arial,helvetica" size=1>
+
+<b>[ DEC / CHAR ]</b><br />
+<textarea cols=48 rows=15 wrap="virtual" name="char" class="ff"><?php
+
+if($char != "") echo $char;
+else if($ascii != "") {
+echo ord(substr($ascii, 0, 1));
+for($i = 1; $i < strlen($ascii); $i = $i + 1)
+echo " ".ord(substr($ascii, $i, 1));
+}
+
+
+?></textarea>
+<br />
+<input type="submit" class="btn" value="&lt; DECODE &gt;">
+</td></form><form method="POST"><td align=center valign=top>
+<font face="verdana,arial,helvetica" size=1>
+
+
+<b>[ MESSAGE DIGEST / CHECK SUM ]</b><br />
+<textarea cols=48 rows=15 wrap="virtual" name="char" class="ff"><?php
+
+$tmpfname = tempnam("/tmp", "xlate");
+$handle = fopen($tmpfname, "w");
+fwrite($handle, $ascii);
+fclose($handle);
+
+#echo "MD2: ".exec("/home/paulscho/bin/md2 $tmpfname")."\n";
+echo "MD2: ".openssl("md2",$tmpfname)."\n";
+#echo "MD4: ".exec("/home/paulscho/bin/md4 $tmpfname")."\n";
+echo "MD4: ".openssl("md4",$tmpfname)."\n";
+echo "MD5: ".md5($ascii)."\n";
+echo "CRC 8, ccitt, 16, 32 : ".
+#  exec("/home/paulscho/bin/crc8 $tmpfname").", ".
+#  exec("/home/paulscho/bin/crcc $tmpfname").", ".
+#  exec("/home/paulscho/bin/crc16 $tmpfname").", ".
+  exec("/usr/bin/crc32 $tmpfname")."\n\n";
+#crc32($ascii)."\n\n";
+echo "CRYPT (form: $ MD5? $ SALT $ CRYPT):\n".crypt($ascii)."\n";
+echo "      (form: SALT[2] CRYPT[11]):\n".crypt($ascii,"ps")."\n\n";
+#include("sha1lib.class.inc.php");
+#$sha = new Sha1Lib;
+
+#echo "SHA1:".base64_encode($sha->str_sha1($ascii))."\n";
+$sha1 = explode("= ",exec("/usr/bin/openssl dgst -sha1 $tmpfname"));
+echo "SHA1: $sha1[1]";
+#$ascii = $sha->str_sha1($ascii);
+#for($i = 1; $i < strlen($ascii); $i = $i + 1) {
+#  $val = dechex(ord(substr($ascii, $i, 1)));
+#  echo "".str_repeat("0", 2-strlen($val)).$val;
+#}
+echo "\n";
+#echo "RIPEMD-160: ".splitn(60,exec("/home/paulscho/bin/ripemd160 $tmpfname"))."\n";
+echo "RIPEMD-160: ".splitn(60,openssl("rmd160",$tmpfname))."\n";
+#echo "SHA2-256: ".split32(exec("/home/paulscho/bin/sha2-256 $tmpfname"))."\n";
+#echo "SHA2-384: ".split32(exec("/home/paulscho/bin/sha2-384 $tmpfname"))."\n";
+#echo "SHA2-512: ".split32(exec("/home/paulscho/bin/sha2-512 $tmpfname"))."\n";
+unlink($tmpfname);
+
+function openssl($dgst = "sha1", $filename) {
+$sha1 = explode("= ",exec("/usr/bin/openssl dgst -$dgst $filename"));
+return trim($sha1[1]);
+}
+
+?></textarea>
+<br />
+(This cannot be decoded<sup>*</sup>)
+</td></tr></form></table>
+
+
+
+<br />
+<sup>*</sup>Cannot be decoded easily (within my lifespan).
+</center>
+<br /><br />
+<?
+function split32($text) {
+	$string = "";
+	for($i = 0; $i < strlen($text); $i = $i + 32) {
+		$string = "$string\n  ".substr($text, $i, 32);
+	}
+	return $string;
+}
+function splitn($n,$text) {
+	$string = "";
+	for($i = 0; $i < strlen($text); $i = $i + $n) {
+		$string = "$string\n  ".substr($text, $i, $n);
+	}
+	return $string;
+}
+?>
+
+</div>
+      <!-- Begin Content -->
+   </div>
+   <!-- End Wrapper -->
+   
+</body>
+</html>