光棍节程序员闯关秀第9关(总共10关) 解题步骤

来源:互联网 发布:三个数据看男女准确率 编辑:程序博客网 时间:2024/05/16 23:48
题目链接:http://segmentfault.com/game/?k=4999c12ce5be7c3cba227ba9f4f7d797
解题步骤:
1. 应景嘛,把所有的空格替换成 1111
2. 8位二进制转换成一个byte, 解释为 ASCII 字符
3. 得到一个 BASE64 加密的字符串
4. 用 BASE64Decoder 解密
5. 另存为 zip 压缩文件
6. 打开文件,发现里面有一幅图片,图片上的字符串就是 key

代码:
    // 从 D 盘的 code.txt 读取数据,输出到 D 盘的 decode.zip
    public void game1111_9() throws IOException {
        File file = new File("D:\\code.txt");
        BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
        StringBuffer sb = new StringBuffer();
        String line = null;
        while ((line = br.readLine()) != null) {
            String[] codes=line.split(" ");
            for(String code:codes){
                char c=(char) Integer.parseInt(code, 2);
                sb.append(c);
            }
        }
        System.out.println(sb);
        BASE64Decoder decoder = new BASE64Decoder();
        byte[] decodeBuffer = decoder.decodeBuffer(sb.toString());
        File decodeFile = new File("D:\\decode.zip");
        FileOutputStream fileOutputStream = new FileOutputStream(decodeFile);
        fileOutputStream.write(decodeBuffer);
        fileOutputStream.close();
        br.close();
    }
原创粉丝点击