题目

中文:
我们从一个挑战者到另一个挑战者拦截了这条消息,也许你可以找到他们在谈论的内容。
为了帮助您完成进度,我编写了一个名为JPK的小型Java应用程序。
注意:该消息很可能是英文的。

原文:
We intercepted this message from one challenger to another, maybe you can find out what they were talking about.
To help you on your progress I coded a small java application, called JPK.
Note: The message is most likely in english.

10101001101000110100111100110100
00011101001100101111100011101000
10000011010011110011010000001101
11010110111000101101001111010001
00000110010111011101100011110111
11100100110010111001000100000110
00011110011110001111010011101001
01011100100000101100111011111110
10111100100100000111000011000011
11001111100111110111110111111100
10110010001000001101001111001101
00000110010111000011110011111100
11110011111010011000011110010111
0100110010111100100101110

解释

题目要求是将上面的数字转换成有用的信息.

JPK

题目提供了一个软件JPK,那就用它来解决。

1.看到0和1,猜测是二进制acsii转换。
ASCII码使用指定的7位或8位二进制数组合来表示128或256种可能的字符。

标准ASCII码也叫基础ASCII码,使用7位二进制数(剩下的1位二进制为0来表示所有的大写和小写字母,数字0到9、标点符号,以及在美式英语中使用的特殊控制字符。

2.用给定的JPK进行Binary Format转换,默认bitsperblock是8,转换后发现多出1位会乱码,换用7

3.最后转成ascii码,用给定的JPK进行Binary to ASCII转换即可。
This text is 7-bit encoded ascii. Your password is easystarter.

提交easystarter即可.
[WeChall] Training: Encodings I (Training, Encoding)

Python3

a='101010011010001101001111001101000001110100110010111110001110100010000011010011110011010000001101110101101110001011010011110100010000011001011101110110001111011111100100110010111001000100000110000111100111100011110100111010010101110010000010110011101111111010111100100100000111000011000011110011111001111101111101111111001011001000100000110100111100110100000110010111000011110011111100111100111110100110000111100101110100110010111100100101110'
for i in range(0,len(a),7):
        print(chr(int(a[i:i+7],2)),end="")

JavaScript

var a = '101010011010001101001111001101000001110100110010111110001110100010000011010011110011010000001101110101101110001011010011110100010000011001011101110110001111011111100100110010111001000100000110000111100111100011110100111010010101110010000010110011101111111010111100100100000111000011000011110011111001111101111101111111001011001000100000110100111100110100000110010111000011110011111100111100111110100110000111100101110100110010111100100101110'
var text = ''
for (var i = 0; i < a.length; i+=7) {

    text += String.fromCharCode(parseInt(a.substr(i, 7), 2))
}
console.log(text)

PHP

<?php
function bin2ascii($texto){
    $tmp = '';
    
    $texto = preg_replace("/[^01]*/", '', $texto);
    
    for($i=0; $i<strlen($texto); $i += 7){
        $tmp .= chr(bindec(substr($texto, $i, 7)));
    }
    return $tmp;
}
 
$txt = '101010011010001101001111001101000001110100110010111110001110100010000011010011110011010000001101110101101110001011010011110100010000011001011101110110001111011111100100110010111001000100000110000111100111100011110100111010010101110010000010110011101111111010111100100100000111000011000011110011111001111101111101111111001011001000100000110100111100110100000110010111000011110011111100111100111110100110000111100101110100110010111100100101110';
 
echo bin2ascii($txt);

?>

C语言

首先需要实现二进制转十进制函数,这里参考了C语言二进制转化为十进制源码,之后用了strncpy函数提取7个字符。

#include <math.h>
#include <stdio.h>
#include <string.h>
 
int bin2dec(char a[])
{
    int n, sum = 0, i = 0;
    n = strlen(a);
    for (i = n - 1; i >= 0; i--)
        sum += (a[i] - '0') * ((int)pow(2, n - 1 - i));
    return sum;
}
 
int main()
{
    int sum = 0;
    char txt[1024] = "101010011010001101001111001101000001110100110010111110001110100010000011010011110011010000001101110101101110001011010011110100010000011001011101110110001111011111100100110010111001000100000110000111100111100011110100111010010101110010000010110011101111111010111100100100000111000011000011110011111001111101111101111111001011001000100000110100111100110100000110010111000011110011111100111100111110100110000111100101110100110010111100100101110";
    char temp[1024];
    for (int i = 0; i < strlen(txt); i+=7)
    {
        strncpy(temp, txt+i, 7);
        sum = bin2dec(temp);
        printf("%c", sum);
    }
}

Bash

这个方法来自[WeChall] Solution in Bash

其中$((2#$a))的意思是: 将2进制转成10进制
printf \\是转义反斜杠,来显示八进制数的ascii码。

ascii=$(echo "101010011010001101001111001101000001110100110010111110001110100010000011010011110011010000001101110101101110001011010011110100010000011001011101110110001111011111100100110010111001000100000110000111100111100011110100111010010101110010000010110011101111111010111100100100000111000011000011110011111001111101111101111111001011001000100000110100111100110100000110010111000011110011111100111100111110100110000111100101110100110010111100100101110" | tr -d '\n' |  sed -r 's/(.{7})/\1\n/g')
for a in $ascii; do printf \\$(printf "%o" $(echo $((2#$a)))); done; echo

参考:
[WeChall] Training: Encodings I (Training, Enco... - 简书

[WeChall] python solution [WeChall]->Solution: Training: Encodings I

[WeChall] omg... [WeChall]->Solution: Training: Encodings I