All pastes #916082 Raw Edit

Something

public text v1 · immutable
#916082 ·published 2008-02-24 09:52 UTC
rendered paste body
import java.io.File;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.FileReader;

public class FlaggedDefucker
{
    public char hexCharacters[] =
            {
                    '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd',
                    'e', 'f'
            };
    public int shiftValues[] =
            {
                    60, 56, 52, 48, 44, 40, 36, 32, 28, 24, 20, 16, 12, 8, 4, 0
            };

    public static void main(String[] args)
    {
        FlaggedDefucker df = new FlaggedDefucker();
        File[] files = new File("./characters/").listFiles();
        try
        {
            df.stripFuckering(files);
        } catch (Exception e)
        {
            e.printStackTrace();
        }
    }

    public void stripFuckering(File[] files) throws IOException
    {
        System.out.println("Stripping lame encryption from " + files.length + " files...");
        for (File file : files)
        {
            BufferedReader reader = new BufferedReader(new FileReader(file));
            String line;
            while ((line = reader.readLine()) != null)
            {
                if (!line.startsWith("character-password")) continue;
                String lameEncryption = line.split(" ")[2];
                System.out.println("    " + file.getName() + ":  " + bytesToHex(getBytes(lameEncryption)));
                break;
            }
            reader.close();
        }
        System.out.println("Finished.");
    }

    public byte[] getBytes(String str)
    {
        byte[] out = new byte[16];
        int index = 0;
        String[] tokens = str.split("-");
        for (String token : tokens)
        {
            int i = new Integer(token);
            out[index++] = (byte) i;
        }
        return out;
    }

    public String bytesToHex(byte[] bytes)
    {
        String x = "";
        for (byte p : bytes) x += byteToHex(p);
        return x;
    }

    public String byteToHex(byte value)
    {
        String s = "";
        for (int j = 0; j < 2; j++)
            s += (hexCharacters[(value >> shiftValues[j + 6]) & 15]);
        return s;
    }

}