求高人指点/**
*
* 以下程序是一个信息编码的程序,阅读其encode部分,并补全其decode部分
最后运行程序,会打印出的一句话。这句话就是我们要求的答案。 注意!这句话是用GBK编码的!
*/
public class Test {
public static void encode(byte[] in, byte[] out, int password)
{
int len = in.length; int seed = password ^ 0x81beff42;
for (int i = 0 ; i < len; ++i) {
byte a = (byte)( ( in[i] ^ seed ) >>> 3 );
byte b = (byte)( ( ( ((int)in[i]) << 20 ) ^ seed ) >>> (20-5) );
a &= 0x1f;
b &= 0xe0;
out[i] = (byte)(a | b);
seed = ((seed ^ in[i]) * 1792013 + in[i]);
}
} public static void decode(byte[] in, byte[] out, int password)
{
int len = in.length; int seed = password ^ 0x81beff42;
for (int i = 0 ; i < len; ++i) {
//要插入的代码
}
}
public static void main(String [] args) throws Exception
{
int password = 0x47e73072;
byte[] buf1 = {-33, 75, -71, 43, -98, 117, 45, -97, 99, 51, 84, 50, -120, -35, 96, 116, 6, 48, 51, 44, 4, -121, 43, 54, 70, 118, -52, 4, 35, -73, -48, 44, 80, -46, 11, -65, -37, 1, };
byte[] buf2 = new byte[buf1.length];
decode(buf1, buf2, password);
System.out.println(new String(buf2, "GBK"));
}
}
int len = in.length;
int seed = password ^ 0x6466913d;
for (int i = 0; i < len; ++i) {
byte a = (byte) (in[i] & 0x1f); //a低五位,实际上是高五位
byte b = (byte) ((in[i] & 0xe0));//b高三位,实际上是低三位
b = (byte) (((((int) b) << ^ seed) >>> 13);
b = (byte) (b&0x7);
a = (byte) (((a << 3) ^ seed) & 0xf8);
out[i] = (byte) (a | b);
seed = (((seed << 7) ^ seed ^ out[i]) + 144123481);
}
}