日期:2014-05-20 浏览次数:20760 次
public class Test { public static void encode(byte[] in, byte[] out, int password) { int len = in.length; int seed = password ^ 0x985729e7; for (int i = 0; i < len; ++i) { byte a = (byte) ((in[i] ^ seed) >>> 3); byte b = (byte) (((((int) in[i]) << 17) ^ seed) >>> (17 - 5)); a &= 0x1f; b &= 0xe0; out[i] = (byte) (a | b); seed = (seed * 608347 + in[i]); } } public static void decode(byte[] in, byte[] out, int password) { int len = in.length; int seed = password ^ 0x985729e7; for (int i = 0; i < len; ++i) { // fill the code here } } public static void main(String[] args) throws Exception { int password = 0x2a7bc155; byte[] buf1 = { -81, -104, -116, 107, 73, -112, 71, 71, 14, 112, -118, -32, -83, -13, -101, -86, 24, -109, 0, -2, 74, 68, 84, -1, 59, 25, 24, -84, 10, -95, 66, -25, }; byte[] buf2 = new byte[buf1.length]; decode(buf1, buf2, password); System.out.println(new String(buf2, "GBK")); } }