gpt4 book ai didi

c - 在位移和或运算之后检索原始位

转载 作者:行者123 更新时间:2023-11-30 21:02:04 28 4
gpt4 key购买 nike

我有两个例程,一个例程发送加密数据,另一个例程解密它。我不确定解析加密字段的正确方法。

void send_the_encrypt_code ( UINT32 field, UINT32 index )
{
UINT32 encrypt_code = ( field << 5 | index );
pass_the_encrypt_code ( encrypt_code );
}

void pass_the_encrypt_code ( UINT32 encrypt_code )
{
UINT32 field ;
UINT32 index;

/* How do I parse the field and index values from the encrypt_code and assign to the local variables field and index in this routine */??

}

提前致谢。

最佳答案

嗯,正如我在评论中所说,我认为不可能恢复这种转变......

如果您只需要打包和隐藏字段,您只需连接数据并应用简单的 XOR 编码...

这样的东西对你有用吗?

请注意,您无法将打包数据存储在与原始数据大小相同的容器中,因此使用 char*。

char key[] = {'P','A','S','S','K','E','Y','1'};

void decrypt ( char * encrypted){
UINT32 field, index;
UINT32 xor_field, xor_index;

memcpy(&xor_field,&encrypted[0],sizeof(xor_field));
memcpy(&xor_index,&encrypted[4],sizeof(xor_index));

memcpy(&field,&key[0],sizeof(field));
memcpy(&index,&key[4],sizeof(index));

field ^= xor_field;
index ^= xor_index;
}

void encrypt ( UINT32 field, UINT32 index ){
char encrypted[8];
UINT32 xor_field, xor_index;

memcpy(&xor_field,&key[0],sizeof(xor_field));
xor_field ^= field;
memcpy(&xor_index,&key[4],sizeof(xor_field));
xor_index ^= index;

memcpy(&encrypted[0],&xor_field,sizeof(xor_field));
memcpy(&encrypted[4],&xor_index,sizeof(xor_index));

decrypt(encrypted);
}

关于c - 在位移和或运算之后检索原始位,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33309348/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com