package googleproxy;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 
package buzzerproxy;


import java.net.*;
import java.io.*;

import org.bouncycastle.util.encoders.Hex;
import org.bouncycastle.crypto.BufferedBlockCipher;
import org.bouncycastle.crypto.paddings.PaddedBufferedBlockCipher;
import org.bouncycastle.crypto.modes.CBCBlockCipher;
import org.bouncycastle.crypto.engines.AESEngine;
import org.bouncycastle.crypto.params.KeyParameter;
import org.bouncycastle.crypto.CryptoException;

*/

/*
public final class AES
{

    public static final String decryptAES(String key, String message) throws Exception
    {

        // Get the KeyGenerator
        KeyGenerator kgen = KeyGenerator.getInstance("AES");
        kgen.init(128); // 192 and 256 bits may not be available

        // Generate the secret key specs.
        SecretKey skey = kgen.generateKey();
        byte[] raw = skey.getEncoded();

        SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES");

        // Instantiate the cipher
        Cipher cipher = Cipher.getInstance("AES");
//////        cipher.init(Cipher.ENCRYPT_MODE, skeySpec);
//////
//////        byte[] encrypted =
//////                cipher.doFinal((args.length == 0
//////                ? "This is just an example" : args[0]).getBytes());
//////        System.out.println("encrypted string: " + asHex(encrypted));

        byte[] theByteArray = message.getBytes();

        cipher.init(Cipher.DECRYPT_MODE, skeySpec);
        byte[] original = cipher.doFinal(theByteArray);
        String originalString = new String(original);
        System.out.println("Original string: " + originalString + " " + asHex(original));

        return originalString;

    }

    public static final String encryptAES(String key, String message) throws Exception
    {

        // Get the KeyGenerator
        KeyGenerator kgen = KeyGenerator.getInstance("AES");
        kgen.init(128); // 192 and 256 bits may not be available

        // Generate the secret key specs.
        SecretKey skey = kgen.generateKey();
        byte[] raw = skey.getEncoded();

        SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES");

        // Instantiate the cipher
        Cipher cipher = Cipher.getInstance("AES");
        cipher.init(Cipher.ENCRYPT_MODE, skeySpec);

        byte[] theByteArray = message.getBytes();
        byte[] encrypted = cipher.doFinal(theByteArray);
        System.out.println("encrypted string: " + asHex(encrypted));

        return asHex(encrypted);

    }
    

    public static String asHex(byte buf[])
    {
        StringBuilder strbuf = new StringBuilder(buf.length * 2);
        int i;

        for (i = 0; i < buf.length; i++)
        {
            if (((int) buf[i] & 0xff) < 0x10)
            {
                strbuf.append("0");
            }

            strbuf.append(Long.toString((int) buf[i] & 0xff, 16));
        }

        return strbuf.toString();
    }

    public static final String unHex(String hex)
    {

        byte[] bytes = new byte[hex.length() / 2];
        for (int i = 0; i < bytes.length; i++)
        {
            bytes[i] = (byte) Integer.parseInt(hex.substring(2 * i, 2 * i + 2), 16);
        }

        String multi = new String(bytes);
        System.out.println(multi);

        return multi;
    }
    
}
 */