【发布时间】:2018-06-05 10:05:13
【问题描述】:
void encrypt_chars(int length)
{
char temp_char;
for (int i = 0; i < length; i++)
{
temp_char = OChars[i];
__asm {
push eax
push ecx
movzx ecx, temp_char
call encrypt_nn
mov temp_char, al
pop ecx
pop eax
}
EChars[i] = temp_char;
}
return;
__asm {
encrypt_nn:
mov eax, ecx
inc eax
ret
}
加密部分很好,但我想我会将代码复制并粘贴到解密中,而不是增加我会减少值,以便它会返回并解密数据
//---------------------------------------------------------------------------------------------------------------
//----------------- DECRYPTION ROUTINES -------------------------------------------------------------------------
//
void decrypt_chars(int length)
{
char temp_char;
for (int i = 0; i < length; i--)
{
temp_char = OChars[i];
__asm {
push eax
push ecx
movzx ecx, temp_char
call encrypt_nn
mov temp_char, al
pop ecx
pop eax
}
EChars[i] = temp_char;
}
return;
}
【问题讨论】:
-
这是汇编语言而不是 c++
-
你有什么问题?
-
所以基本上你只需从数组中取出一个字符并将其递增 1,然后将后半部分存储回数组中?这不是一个很好的加密。基本上你只需要 dec ecx 并且你得到了 char [编辑:这不是称为“cesar 的加密”吗?]
-
是的,我正在尝试进行 cesar 的加密,但我不太擅长汇编语言。
-
谢谢,我刚刚注意到我的一些错误