本帖最后由 jixun66 于 2020-10-21 05:08 编辑
来玩算法呀
用户名 微软用户
机器码 JSYDY - OTNJD - SRAYD - PQQXY - RPMSX - TMEJB
注册码 BAEPE - SZMLC - PTHJU - VZICS - OIKNP - WFWFM
不放代码好像不太好,就放个 30 长度的定长字符串编码解码函数吧(应该是 BASE30?)。
#include "str_encode.h"
#include <cstring>
#include <cstdio>
char table_5F9714[] = "jqschwartz{flung|dvpike}my~box";
uint8_t table_5F9714_plain[30] = {};
uint8_t table_5F9714_output_index[30] = {}; // / 6
uint8_t table_5F9714_table_index[30] = {}; // % 6
uint8_t table_5F9714_rev[5][6] = {};
uint32_t table_5F96FC[6] = {
0x01, 0x1A, 0x2A4,
0x44A8, 0x6F910, 0x0B54BA0,
};
// 初始化码表
void init_str_encode_table() {
for (int i = 0; i < 30; i++) {
uint8_t v = table_5F9714_plain[i] = table_5F9714[i] - 'a';
uint8_t a = v / 6;
uint8_t b = v % 6;
table_5F9714_output_index[i] = a;
table_5F9714_table_index[i] = b;
table_5F9714_rev[a][b] = i;
}
}
// 30 字节的内容变化
// data: uint32_t data[5] = {}
void sub_41E5A0(uint32_t* data, wchar_t* input) {
uint8_t code;
int inputLen = wcslen(input);
for (int i = 0; i < 30; i++) {
uint8_t code = table_5F9714_plain[i];
wchar_t inputChar = input[i];
if (inputChar >= 'A' && inputChar <= 'Z') {
uint32_t adder = table_5F96FC[table_5F9714_table_index[i]] * (inputChar - 'A');
data[table_5F9714_output_index[i]] += adder;
}
}
}
void sub_41E5A0_rev(wchar_t* output, uint32_t* input) {
for (int i = 0; i < 5; i++) {
uint32_t code = input[i];
for (int j = 5; j >= 0; j--) {
uint32_t v = table_5F96FC[j];
int outIdx = table_5F9714_rev[i][j];
output[outIdx] = 'A' + int(code / v);
code = code % v;
}
}
}
|