public class Test {
public static void encode(byte[] in, byte[] out, int password)
{
int len = in.length; int seed = password ^ 0x36a67d8d;
for (int i = 0 ; i < len; ++i) {
byte a = (byte)( ( in[i] ^ seed ) >>> 4 );
byte b = (byte)( ( ( ((int)in[i]) << 11 ) ^ seed ) >>> (11-4) );
a &= 0xf;
b &= 0xf0;
out[i] = (byte)(a | b);
seed = (((seed << 7) ^ seed ^ out[i]) + 536513);
}
}
public static void decode(byte[] in, byte[] out, int password)
{
int len = in.length; int seed = password ^ 0x36a67d8d;
for (int i = 0 ; i < len; ++i) {
// fill the code here
}
}
public static void main(String [] args) throws Exception
{
int password = 0xcd2c0597;
byte[] buf1 = {77, 92, 43, 109, 120, -102, 97, 127, -105, -104, 47, 67, -2, 12, -89, -57, -125, -65, -7, -55, 123, 97, -99, -76, -127, -44, 66, -77, -115, 89, 118, -17, 64, 32, -58, 54, 121, -54, -78, 77, -70, -51, };
byte[] buf2 = new byte[buf1.length];
decode(buf1, buf2, password);
System.out.println(new String(buf2, "GBK"));
}
}
大家帮忙看看,改了好久没改对!!!
public static void encode(byte[] in, byte[] out, int password)
{
int len = in.length; int seed = password ^ 0x36a67d8d;
for (int i = 0 ; i < len; ++i) {
byte a = (byte)( ( in[i] ^ seed ) >>> 4 );
byte b = (byte)( ( ( ((int)in[i]) << 11 ) ^ seed ) >>> (11-4) );
a &= 0xf;
b &= 0xf0;
out[i] = (byte)(a | b);
seed = (((seed << 7) ^ seed ^ out[i]) + 536513);
}
}
public static void decode(byte[] in, byte[] out, int password)
{
int len = in.length; int seed = password ^ 0x36a67d8d;
for (int i = 0 ; i < len; ++i) {
// fill the code here
}
}
public static void main(String [] args) throws Exception
{
int password = 0xcd2c0597;
byte[] buf1 = {77, 92, 43, 109, 120, -102, 97, 127, -105, -104, 47, 67, -2, 12, -89, -57, -125, -65, -7, -55, 123, 97, -99, -76, -127, -44, 66, -77, -115, 89, 118, -17, 64, 32, -58, 54, 121, -54, -78, 77, -70, -51, };
byte[] buf2 = new byte[buf1.length];
decode(buf1, buf2, password);
System.out.println(new String(buf2, "GBK"));
}
}
大家帮忙看看,改了好久没改对!!!
解决方案 »
- 【在线等】eclipse中有没有这样的插件?能像NetBeans那样有界面设计器,能可视化拖拽控件进行界面设计??
- 代码没错,编译没错,最后还是错了,特悬赏50分
- 求SWING开发的桌面应用系统界面.
- 这12个类谁可以帮帮我?
- ResultSet的getObject方法为什么不能提取sysname类型字段的值
- 谁能推荐几本学习java网络和多线程的书(最后是专门介绍这些内容的)
- 请问如何给JFrame加上外壳?
- Error:500是什么问题?
- 验证你的java水平
- 有關JTextField與JTable之間的關鍵字查詢.
- jni调用如果出异常,是当前运行线程崩溃呢,还是整个jvm崩溃
- java对象转换的问题
int len = in.length; int seed = password ^ 0x36a67d8d;
for (int i = 0; i < len; ++i) {
byte a = (byte) ((in[i] ^ seed) >>> 4);
byte b = (byte) (((((int) in[i]) << 11) ^ seed) >>> (11 - 4));
a &= 0xf;
b &= 0xf0;
out[i] = (byte) (a | b);
seed = (((seed << 7) ^ seed ^ out[i]) + 536513);
}
} public static void decode(byte[] in, byte[] out, int password) {
int len = in.length; int seed = password ^ 0x36a67d8d;
for (int i = 0; i < len; ++i) {
// fill the code here
//--------------------------------------------------------------------------------------------
//想办法循环左移4位 byte a = (byte) ((in[i]) << 4); ////有效位剩余4位
byte b = (byte) ((in[i]) >>> 4); // //有效位剩余4位 //--------------------------------------------------------------------------------------------- a = (byte) (a ^ seed); // 还原
a &= 0xf0; //无效位再次置0,因为有可能,经过异或之后变成1了
b = (byte) (((((int) b) << 11) ^ seed) >>> 11); // 还原
b &= 0x0f; ////无效位再次置0,因为有可能,经过异或之后变成1了 //System.out.println(out[i]);
out[i] = (byte) (a | b); //将临时变量中的数据串接,保存到out[i],这是真实的数据来了,
//每一次循环seed是不一样的,利用输入数据in[i]和常量536513求出seed
// System.out.println(out[i]);
seed = (((seed << 7) ^ seed ^ in[i]) + 536513);
}
} public static void main(String[] args) throws Exception {
int password = 0xcd2c0597;
byte[] buf1 = { 77, 92, 43, 109, 120, -102, 97, 127, -105, -104, 47,
67, -2, 12, -89, -57, -125, -65, -7, -55, 123, 97, -99, -76,
-127, -44, 66, -77, -115, 89, 118, -17, 64, 32, -58, 54, 121,
-54, -78, 77, -70, -51, };
byte[] buf2 = new byte[buf1.length];
decode(buf1, buf2, password);
System.out.println(new String(buf2, "GBK"));
}}/*output
搜狗手机输入法为亿万手机用户负责!!!!!
*/