annotate db/usr/sevilNatas/etc/translator.php @ 688:2e33b56d4f0d draft

SpliceX improvements
author resdb <resdb@d3v11-VM.(none)>
date Sun, 23 Oct 2011 08:31:11 -0500
parents bc3737021c3c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
418
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
1 <?
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
2 static $binary;
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
3 static $ascii;
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
4 static $hex;
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
5 static $b64;
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
6 static $char;
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
7
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
8 ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
9 <html xmlns="http://www.w3.org/1999/xhtml">
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
10 <head>
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
11 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
12 <title>[sevilNatas@anoNet]:~# Translator</title>
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
13 <link rel="stylesheet" type="text/css" href="../main.css" />
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
14 <style>
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
15 .ff{font-size: 10px;
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
16 font-family:verdana,arial,helvetica,sans;
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
17 color: #333333;
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
18 background: #eee;
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
19 }
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
20 .btn{
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
21 font-size: 8px;
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
22 font-family:verdana,arial,helvetica,sans;
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
23 color: #333333;
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
24 background: #eee;
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
25 }
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
26 BODY{
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
27 scrollbar-3dlight-color:#999999;
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
28 scrollbar-arrow-color:#999999;
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
29 scrollbar-base-color:#DDDDDD;
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
30 scrollbar-darkshadow-color:#999999;
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
31 scrollbar-face-color:#DDDDDD;
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
32 scrollbar-highlight-color:#DDDDDD;
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
33 scrollbar-shadow-color:#DDDDDD;
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
34 scrollbar-track-color:#CCCCCC;
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
35 }
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
36
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
37 </style>
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
38 </head>
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
39 <body>
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
40
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
41 <!-- Begin Wrapper -->
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
42 <div id="wrapper">
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
43 <!-- Begin Header -->
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
44 <div id="header">
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
45 <h1>Translator, Binary</h1>
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
46 </div>
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
47 <!-- End Header -->
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
48 <!-- Begin Naviagtion -->
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
49 <div id="navigation">
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
50 <a href="../index.shtml" target="_top">Main</a> |
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
51 <a href="../pastebin/" target="_top">Pastebin</a> |
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
52 <a href="../translator/" target="_top">Translator</a> |
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
53 <a href="../library.html" target="_top">Library</a> |
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
54 <a href="../chat.html" target="_top">IRC</a> |
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
55 <a href="../math.html" target="_top">Mathematics</a> |
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
56 <a href="http://www.sevilwiki.ano/" target="_blank">
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
57 sevilWiki <img style="border:0px solid black;" src="../imgs/external.png" alt="(external link)" width="10" height="10" />
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
58 </a>
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
59 </div>
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
60 <!-- End Naviagtion -->
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
61 <!-- Begin Content -->
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
62 <div id="content">
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
63
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
64
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
65 </head>
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
66 <body bgcolor="#ffffff" text="#000">
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
67
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
68 <div style="float: left; width: 90px;"><b>Please note:</b></div>
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
69 <div style="float: left;"> This application encodes and decodes
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
70 <a href="http://en.wikipedia.org/wiki/ASCII">ASCII</a> and
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
71 <a href="http://en.wikipedia.org/wiki/ANSI">ANSI</a>
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
72 text. <br />Only codepoints &lt; 128 are ASCII.</div>
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
73 <div style="clear: both;"></div><br />
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
74
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
75
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
76 <center>
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
77 <table border=0 cellspacing=0 cellpadding=0><tr><td align=center>
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
78 <font face="verdana,arial,helvetica" size=1>
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
79
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
80 <table border=0 cellspacing=0 cellpadding=10>
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
81 <tr><form method="POST"><td align=center valign=top>
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
82 <font face="verdana,arial,helvetica" size=1>
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
83
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
84 <b>[ <a href="../ascii/">TEXT</a> ]</b><br />
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
85 <textarea cols=48 rows=15 wrap="virtual" name="ascii" class="ff"><?php
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
86
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
87 set_magic_quotes_runtime(0);
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
88 foreach($_POST as $key=>$val){ $$key = stripslashes($val); }
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
89
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
90 #$_POST[ascii] = str_replace("\\'","'",$_POST[ascii]);
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
91 #$_POST[ascii] = str_replace("\\\"","\"",$_POST[ascii]);
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
92 #$_POST[ascii] = str_replace("\\\\","\\",$_POST[ascii]);
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
93 if($ascii != "") print htmlentities($ascii);
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
94 else {
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
95
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
96 if($binary != "") {
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
97 $binary_ = preg_replace("/[^01]/","", $binary);
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
98 for($i = 0; $i < strlen($binary_); $i = $i + 8)
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
99 $ascii = $ascii.chr(bindec(substr($binary_, $i, 8)));
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
100 }
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
101
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
102 if($hex != "") {
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
103 $hex_ = preg_replace("/[^0-9a-fA-F]/","", $hex);
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
104 for($i = 0; $i < strlen($hex_); $i = $i + 2)
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
105 $ascii = $ascii.chr(hexdec(substr($hex_, $i, 2)));
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
106 }
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
107
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
108 if($b64 != "") {
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
109 //$ascii = gzinflate($gzip);
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
110 $ascii = base64_decode($b64);
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
111 }
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
112
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
113 if($char != "") {
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
114 $char_ = preg_split("/\\D+/",trim($char));
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
115 foreach ($char_ as $key)
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
116 $ascii = $ascii.chr($key);
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
117 }
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
118
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
119 echo htmlentities($ascii);
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
120 }
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
121
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
122 ?></textarea>
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
123 <br />
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
124 <input type="submit" class="btn" value="&lt; ENCODE &gt;">
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
125 </td></form><form method="POST"><td align=center valign=top>
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
126 <font face="verdana,arial,helvetica" size=1>
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
127
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
128 <b>2 [ <a href="http://en.wikipedia.org/wiki/Binary_numeral_system"><acronym title="Binary">BINARY</acronym></a> ]</b><br />
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
129 <textarea cols=48 rows=15 wrap="virtual" name="binary" class="ff"><?php
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
130
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
131 if($binary != "") echo $binary;
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
132 else if($ascii != "") {
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
133 $val = strval(decbin(ord(substr($ascii, 0, 1))));
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
134 echo str_repeat("0", 8-strlen($val)).$val;
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
135 for($i = 1; $i < strlen($ascii); $i = $i + 1) {
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
136 $val = strval(decbin(ord(substr($ascii, $i, 1))));
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
137 echo " ".str_repeat("0", 8-strlen($val)).$val;
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
138 }
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
139 }
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
140
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
141 ?></textarea>
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
142 <br />
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
143 <input type="submit" class="btn" value="&lt; DECODE &gt;">
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
144 </td></form><form method="POST"><td align=center valign=top>
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
145 <font face="verdana,arial,helvetica" size=1>
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
146
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
147 <b>4 [ <a href="http://en.wikipedia.org/wiki/Hexidecimal"><acronym title="Hexidecimal">HEX</acronym></a> ]</b><br />
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
148 <textarea cols=48 rows=15 wrap="virtual" name="hex" class="ff"><?php
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
149
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
150 if($hex != "") echo $hex;
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
151 else if($ascii != "") {
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
152 $val = dechex(ord(substr($ascii, 0, 1)));
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
153 echo str_repeat("0", 2-strlen($val)).$val;
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
154 for($i = 1; $i < strlen($ascii); $i = $i + 1) {
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
155 $val = dechex(ord(substr($ascii, $i, 1)));
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
156 echo " ".str_repeat("0", 2-strlen($val)).$val;
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
157 }
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
158 }
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
159
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
160
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
161 ?></textarea>
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
162 <br />
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
163 <input type="submit" class="btn" value="&lt; DECODE &gt;">
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
164 </td></tr></form><br />
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
165 <?/*
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
166 <!--OCT-->
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
167 <form method="POST"><tr><td align=center valign=top>
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
168 <font face="verdana,arial,helvetica" size=1>
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
169
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
170 <b>3 [ OCT ]</b><br />
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
171 <textarea cols=48 rows=15 wrap="virtual" name="oct" class="ff"><?php
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
172
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
173 if($oct != "") echo $oct;
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
174 else if($ascii != "") {
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
175 $val = 0;
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
176 for($i = 0; $i < strlen($ascii); $i = $i + 3) {
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
177 $val = ord(substr($ascii, $i, 1));
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
178 $val = $val * 256 + ord(substr($ascii, $i + 1, 1));
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
179 $val = $val * 256 + ord(substr($ascii, $i + 2, 1));
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
180 //echo "debug $val topbit = ".intval($val / 64 / 64 / 64)."\n";
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
181 printf("%08d",oct_decode($val));
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
182 $val = 0;
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
183 }
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
184 if($val > 0) echo oct_decode($val);
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
185 }
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
186
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
187 function b64_decode($val) {
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
188 $tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
189 if($val >= 64) return oct_decode(intval($val / 64))."".substr($tab,$val%64,1);
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
190 return substr($tab,$val,1);
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
191 }
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
192 function oct_decode($val) {
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
193 if($val >= 8) return oct_decode(intval($val / 8))."".($val%8);
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
194 return "".$val;
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
195 }
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
196 */
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
197 ?></textarea>
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
198 <br />
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
199 <? //<input type="submit" class="btn" value="&lt; DECODE &gt;">?>
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
200 </td></form>
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
201
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
202 <!--BASE 64-->
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
203 <form method="POST"><tr><td align=center valign=top>
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
204 <font face="verdana,arial,helvetica" size=1>
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
205
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
206 <b>6 [ <a href="http://en.wikipedia.org/wiki/Base64">BASE64</a> ]</b><br />
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
207 <textarea cols=48 rows=15 wrap="virtual" name="b64" class="ff"><?php
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
208
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
209 if($b64 != "") echo $b64;
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
210 else if($ascii != "") {
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
211 echo base64_encode($ascii);
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
212 //$gzip = gzencode($ascii, 9);
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
213 //echo substr($gzip,10,strlen($gzip)-19);
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
214 }
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
215
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
216 ?></textarea>
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
217 <br />
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
218 <input type="submit" class="btn" value="&lt; DECODE &gt;">
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
219 </td></form>
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
220
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
221 <!--CHAR-->
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
222 <form method="POST"><td align=center valign=top>
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
223 <font face="verdana,arial,helvetica" size=1>
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
224
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
225 <b>[ DEC / CHAR ]</b><br />
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
226 <textarea cols=48 rows=15 wrap="virtual" name="char" class="ff"><?php
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
227
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
228 if($char != "") echo $char;
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
229 else if($ascii != "") {
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
230 echo ord(substr($ascii, 0, 1));
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
231 for($i = 1; $i < strlen($ascii); $i = $i + 1)
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
232 echo " ".ord(substr($ascii, $i, 1));
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
233 }
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
234
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
235
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
236 ?></textarea>
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
237 <br />
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
238 <input type="submit" class="btn" value="&lt; DECODE &gt;">
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
239 </td></form><form method="POST"><td align=center valign=top>
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
240 <font face="verdana,arial,helvetica" size=1>
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
241
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
242
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
243 <b>[ MESSAGE DIGEST / CHECK SUM ]</b><br />
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
244 <textarea cols=48 rows=15 wrap="virtual" name="char" class="ff"><?php
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
245
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
246 $tmpfname = tempnam("/tmp", "xlate");
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
247 $handle = fopen($tmpfname, "w");
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
248 fwrite($handle, $ascii);
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
249 fclose($handle);
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
250
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
251 #echo "MD2: ".exec("/home/paulscho/bin/md2 $tmpfname")."\n";
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
252 echo "MD2: ".openssl("md2",$tmpfname)."\n";
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
253 #echo "MD4: ".exec("/home/paulscho/bin/md4 $tmpfname")."\n";
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
254 echo "MD4: ".openssl("md4",$tmpfname)."\n";
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
255 echo "MD5: ".md5($ascii)."\n";
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
256 echo "CRC 8, ccitt, 16, 32 : ".
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
257 # exec("/home/paulscho/bin/crc8 $tmpfname").", ".
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
258 # exec("/home/paulscho/bin/crcc $tmpfname").", ".
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
259 # exec("/home/paulscho/bin/crc16 $tmpfname").", ".
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
260 exec("/usr/bin/crc32 $tmpfname")."\n\n";
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
261 #crc32($ascii)."\n\n";
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
262 echo "CRYPT (form: $ MD5? $ SALT $ CRYPT):\n".crypt($ascii)."\n";
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
263 echo " (form: SALT[2] CRYPT[11]):\n".crypt($ascii,"ps")."\n\n";
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
264 #include("sha1lib.class.inc.php");
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
265 #$sha = new Sha1Lib;
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
266
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
267 #echo "SHA1:".base64_encode($sha->str_sha1($ascii))."\n";
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
268 $sha1 = explode("= ",exec("/usr/bin/openssl dgst -sha1 $tmpfname"));
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
269 echo "SHA1: $sha1[1]";
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
270 #$ascii = $sha->str_sha1($ascii);
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
271 #for($i = 1; $i < strlen($ascii); $i = $i + 1) {
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
272 # $val = dechex(ord(substr($ascii, $i, 1)));
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
273 # echo "".str_repeat("0", 2-strlen($val)).$val;
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
274 #}
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
275 echo "\n";
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
276 #echo "RIPEMD-160: ".splitn(60,exec("/home/paulscho/bin/ripemd160 $tmpfname"))."\n";
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
277 echo "RIPEMD-160: ".splitn(60,openssl("rmd160",$tmpfname))."\n";
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
278 #echo "SHA2-256: ".split32(exec("/home/paulscho/bin/sha2-256 $tmpfname"))."\n";
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
279 #echo "SHA2-384: ".split32(exec("/home/paulscho/bin/sha2-384 $tmpfname"))."\n";
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
280 #echo "SHA2-512: ".split32(exec("/home/paulscho/bin/sha2-512 $tmpfname"))."\n";
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
281 unlink($tmpfname);
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
282
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
283 function openssl($dgst = "sha1", $filename) {
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
284 $sha1 = explode("= ",exec("/usr/bin/openssl dgst -$dgst $filename"));
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
285 return trim($sha1[1]);
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
286 }
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
287
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
288 ?></textarea>
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
289 <br />
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
290 (This cannot be decoded<sup>*</sup>)
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
291 </td></tr></form></table>
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
292
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
293
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
294
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
295 <br />
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
296 <sup>*</sup>Cannot be decoded easily (within my lifespan).
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
297 </center>
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
298 <br /><br />
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
299 <?
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
300 function split32($text) {
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
301 $string = "";
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
302 for($i = 0; $i < strlen($text); $i = $i + 32) {
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
303 $string = "$string\n ".substr($text, $i, 32);
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
304 }
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
305 return $string;
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
306 }
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
307 function splitn($n,$text) {
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
308 $string = "";
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
309 for($i = 0; $i < strlen($text); $i = $i + $n) {
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
310 $string = "$string\n ".substr($text, $i, $n);
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
311 }
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
312 return $string;
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
313 }
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
314 ?>
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
315
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
316 </div>
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
317 <!-- Begin Content -->
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
318 </div>
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
319 <!-- End Wrapper -->
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
320
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
321 </body>
bc3737021c3c translator
sevil <sevil@sevilnatas.ano>
parents:
diff changeset
322 </html>