招聘笔试题

搜狗笔试真题

-- #include "stdint.h"

// 注:以上内容没有前面的“--”,做时去掉即可

int encode(const void raw_in, void raw_out, uint32_t password, size_t len)

{

const uint8_t in = (const uint8_t)raw_in;

uint8_t out = (uint8_t)raw_out;

uint32_t seed = password ^ 0x42381238u;

for (size_t i = 0 ; i < len; ++i) {

uint8_t a = ( in[i] ^ seed ) >> 2;

uint8_t b = ( ( ((uint32_t)in[i]) << 10 ) ^ seed ) >> (10-6);

a &= 63;

b &= 192;

a = 63 & ( a ^ (b << 3));

out[i] = a | b;

seed = (((seed << 7) ^ seed ^ in[i]) + 48475829);

}

return 0;

}

int decode(const void raw_in, void raw_out, uint32_t password, size_t len)

{

const uint8_t in = (const uint8_t)raw_in;

uint8_t out = (uint8_t)raw_out;

uint32_t seed = password ^ 0x42381238u;

for (size_t i = 0 ; i < len; ++i) {

// 请在此处补全代码

}

}

int main()

{

const uint8_t buf1[] = {0xf5, 0x3b, 0x3a, 0x0d, 0x54, 0x73, 0x34, 0xfe, 0x5d, 0x72, 0x2d, 0x8b, 0xca, 0x1d, 0xdb, 0xd4, 0x94, 0xfa, 0x88, 0xae, 0x51, 0x4f, 0x85, 0x38, 0x96, 0x33, 0xf1, 0xa3, 0x41, 0xf9, 0xc8, 0x67, 0xfc, 0x01, 0xc7, 0xdd, 0x22, 0xe7, 0xbd, 0x83, };

uint8_t buf2[100] = {};

const uint32_t password = 0x266d183bu;

const size_t len = sizeof(buf1);

encode(buf1, buf2, password, len);

printf("%s\n", buf2);

}

求哈希解码算法

阅读了本文,本站思而学教育网(cnrencai)笔试频道,还为你提供以下可能你会感兴趣的笔试题相关文章:

设备监理师笔试试题

ABB笔试真题

艾默生软件工程师笔试题

大家都在看