-- #include "stdint.h"
// 注:以上內(nèi)容沒有前面的“--”,做時去掉即可
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);
}
求哈希解碼算法
閱讀了本文,本站中國人才網(wǎng)(cnrencai)筆試頻道,還為你提供以下可能你會感興趣的筆試題相關(guān)文章: