求助。。。测评题

summer_0123 2011-09-14 12:43:03
以下程序是一个信息编码的程序,阅读其encode部分,并补全其decode部分
最后运行程序,会打印出的一句话。这句话就是我们要求的答案。

注意!这句话是用GBK编码的!
答案请复制粘贴, 不要手动输入
每次重新登录时请重新答题


public class Test {


public static void encode(byte[] in, byte[] out, int password)
{
int len = in.length;

int seed = password ^ 0xb3525314;
for (int i = 0 ; i < len; ++i) {
byte a = (byte)( ( in[i] ^ seed ) >>> 1 );
byte b = (byte)( ( ( ((int)in[i]) << 19 ) ^ seed ) >>> (19-7) );
a &= 0x7f;
b &= 0x80;
out[i] = (byte)(a | b);
seed = (seed * 1792013 ^ seed ^ in[i]);
}
}


public static void decode(byte[] in, byte[] out, int password)
{
int len = in.length;

int seed = password ^ 0xb3525314;
for (int i = 0 ; i < len; ++i) {
// fill the code here
}
}
public static void main(String [] args) throws Exception
{
int password = 0x7edcf276;
byte[] buf1 = {84, 65, 6, 69, 59, 87, -73, -90, 75, -72, -71, -112, 41, -28, -99, 33, -78, 77, -72, -1, -72, -20, -19, 102, 48, -80, -37, -69, 64, -86, -63, -5, 66, 23, 15, -24, -9, -55, 83, 35, 47, -109, 47, 19, };
byte[] buf2 = new byte[buf1.length];
decode(buf1, buf2, password);
System.out.println(new String(buf2, "GBK"));
}


}
...全文
327 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
huzhen1025 2011-09-21
  • 打赏
  • 举报
回复
搜狗浏览器提出了业界首创的防假死功能!!!!
zhangxixrh 2011-09-15
  • 打赏
  • 举报
回复
能不能解释哈 为什么那么写 特别是a = (byte)(((a << 1) ^ seed) & 0xfe);
b = (byte)((((((int)b) << (19-7)) ^ seed) >> 19) & 0x01);
的0xfe和0x01是怎么来的啊
安心逍遥 2011-09-14
  • 打赏
  • 举报
回复
http://topic.csdn.net/u/20110912/15/f6b2d10f-3a9c-4e87-84f0-7b960299d80c.html

softroad 2011-09-14
  • 打赏
  • 举报
回复
位运算
qybao 2011-09-14
  • 打赏
  • 举报
回复
又是这种题,现在比上眼睛都能写了

http://topic.csdn.net/u/20110912/15/f6b2d10f-3a9c-4e87-84f0-7b960299d80c.html

public static void decode(byte[] in, byte[] out, int password) {  
int len = in.length;

int seed = password ^ 0xb3525314;
for (int i = 0 ; i < len; ++i) {
byte a = (byte)(in[i] & 0x7f);
byte b = (byte)(in[i] & 0x80);
a = (byte)(((a << 1) ^ seed) & 0xfe);
b = (byte)((((((int)b) << (19-7)) ^ seed) >> 19) & 0x01);
out[i] = (byte)(a | b);
seed = (seed * 1792013 ^ seed ^ out[i]);
}
}

50,531

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧