Version: 1.0

Type: Function

Category: Algorithms

Description: These functions will decode the so called encryption algorithm that the cuecat scans in, resulting in usable data.

```<?
/*

This is not the best code, this is just code that works.  Feel free to change this however you see fit, though, if you do something cool with it, drop an email to adam@joygasmic.com.  Also, if you are inclined to rewrite this to make it work better and faster, please tell me.  Efficiency is usually the last thing on my mind at 4am.

*/

function swap(\$input) {
for (\$i = 0; \$i < strlen(\$input); \$i++){
if ((ord(\$input[\$i]) > 64) && (ord(\$input[\$i]) < 123)){
if ((ord(\$input[\$i]) > 64) && (ord(\$input[\$i]) < 91)) {
\$str .= chr((ord(\$input[\$i]) + 32));
}
else if ((ord(\$input[\$i]) > 96) && (ord(\$input[\$i]) < 123)) {
\$str .= chr((ord(\$input[\$i]) - 32));
}
}
else
\$str .= \$input[\$i];
}
return \$str;
}

function catdecode(\$str) {
\$str = swap(\$str);
\$str = str_replace("-","/",\$str);
\$str = explode(".",\$str);
\$str3 = base64_decode(\$str[1]);
\$str2 = base64_decode(\$str[2]);
\$str = base64_decode(\$str[3]);
for (\$i = 0; \$i < strlen(\$str); \$i++) {
\$newstr .= chr(ord(\$str[\$i]) ^ 67);
}
for (\$i = 0; \$i < strlen(\$str2); \$i++) {
\$newstr2 .= chr(ord(\$str2[\$i]) ^ 67);
}
for (\$i = 0; \$i < strlen(\$str3); \$i++) {
\$newstr3 .= chr(ord(\$str3[\$i]) ^ 67);
}
return array("id" => \$newstr3, "type" => \$newstr2, "code" => \$newstr);

}
if (\$submit) {
//Sample Code
echo \$input."<br>";

\$str = catdecode(\$input);

echo "ID: ".\$str[id]."<br>";
echo "Type: ".\$str[type]."<br>";
echo "Code: ".\$str[code]."<br>";
}
?>
<FORM ACTION=cuecat.php METHOD=POST>
<br>
<INPUT TYPE=TEXT NAME=input><BR>
<INPUT TYPE=SUBMIT NAME=submit>
</FORM>
```