packagecom.BFGJ.AES;importjava.util.Random;importjava.util.StringTokenizer;importjavax.crypto.Cipher;importjavax.crypto.SecretKey;importjavax.crypto.SecretKeyFactory;importjavax.crypto.spec.PBEKeySpec;importjavax.crypto.spec.PBEParameterSpec;importjavax.crypto.spec.SecretKeySpec;/*** PBEWithMD5AndDES算法加密解密
*
*@authorJson
*@version
*/
public class EncryptImpl implementsEncrypt
{publicEncryptImpl()
{
}private final static Encrypt encrypt= newEncryptImpl();private final String password="e_f_codd";private final String encoding="GBK";/*** 16进制字符数组*/
private final static String[] hexDigits ={"0", "1", "2", "3", "4", "5", "6", "7","8", "9", "a", "b", "c", "d", "e", "f"};/*** AES密匙*/
private final static byte[] keyByte ={0x11, 0x22, 0x4F, 0x58, (byte)0x88, 0x10, 0x40, 0x38,0x28, 0x25, 0x79, 0x51, (byte)0xCB, (byte)0xDD, 0x55,0x66}; //16字节的密钥,可以改变
/*** 一位Byte到16进制字符串的转换
*@paramb byte
*@returnString*/
private static String byteToHexString(byteb)
{int n =b;if(n < 0)
{
n= 256 +n;
}int d1 = n / 16;int d2 = n % 16;return hexDigits[d1] +hexDigits[d2];
}/*** Byte数组到16进制字符串的转换
*@paramb byte[]
*@returnString*/
private static String byteArrayToHexString(byte[] b)
{
StringBuffer resultSb= newStringBuffer();for(int i = 0; i < b.length; i++)
{
resultSb.