Java habbo encoding class'svl64/wire:Class's taken from Jase / Woodpecker II and ported to Java please leave the @author comments intact if you distribute / use this
base64:PHP Code:package com.encoding;
/*
* vl64 encoding for habbo servers in Java
*
* @author Who ever wrote the C# version, Lord Jordan Porting
*/
public class vl64Habbo {
public static String Encode(int i)
{
byte[] wf = new byte[6];
int pos = 0;
int startPos = pos;
int bytes = 1;
int negativeMask = i >= 0 ? 0 : 4;
i = Math.abs(i);
wf[pos++] = (byte)(64 + (i & 3));
for (i >>= 2; i != 0; i >>= 6)
{
bytes++;
wf[pos++] = (byte)(64 + (i & 0x3f));
}
wf[startPos] = (byte)(wf[startPos] | bytes << 3 | negativeMask);
String tmp = new String(wf); //encoder.GetString(wf);
return tmp.replace("\0", "");
}
public static int Decode(String data)
{
char[] chars;
chars = data.toCharArray();
return Decode(chars);
}
public static int Decode(char[] raw)
{
try {
int pos = 0;
int v = 0;
boolean negative = (raw[pos] & 4) == 4;
int totalBytes = raw[pos] >> 3 & 7;
v = raw[pos] & 3;
pos++;
int shiftAmount = 2;
for (int b = 1; b < totalBytes; b++)
{
v |= (raw[pos] & 0x3f) << shiftAmount;
shiftAmount = 2 + 6 * b;
pos++;
}
if (negative == true)
v *= -1;
return v;
}
catch (Exception e) {
return 0;
}
}
}
PHP Code:package com.encoding;
/*
* base64 encoding for habbo servers in Java
*
* @author Who ever wrote the C# version, Lord Jordan Porting
*/
public class base64Habbo {
public static String Encode(int i)
{
try
{
String s = "";
for (int x = 1; x <= 2; x++)
s += (char)((byte)(64 + (i >> 6 * (2 - x) & 0x3f)));
return s;
}
catch (Exception e)
{
System.out.println(e.toString());
return "";
}
}
public static int Decode(String s)
{
try
{
char[] val = s.toCharArray();
int intTot = 0;
int y = 0;
for (int x = (val.length - 1); x >= 0; x--)
{
int intTmp = (int)(byte)((val[x] - 64));
if (y > 0)
intTmp = intTmp * (int)(Math.pow(64, y));
intTot += intTmp;
y++;
}
return intTot;
}
catch (Exception e)
{
System.out.println(e.toString());
return 0;
}
}
}



![[Java] vl64 & base64 encoding](http://ragezone.com/hyper728.png)




