可能重复:
如何解密此加密例程?
我已经参加这个项目一个星期了,我很困惑。我尝试了一切,但我没能成功。如果您能为我的程序提供一些帮助,我将不胜感激。谢谢你。
我有以下代码,我需要为它编写解密例程。
OChars = Original char -> is the word which the user types in.
EKey = The Encryption Key (one letter)
Length = The length of characters that the user needs to put
EChars = Stores the Encrypted characters in so the decryption routine can use it to decrypt it.
void encrypt_chars (int length, char EKey){
char temp_char; // original/encrypted char temporary store
for (int i = 0; i < length; i++){
temp_char = OChars [i]; // get next char from original string
__asm { // call the encrypt subroutine
push eax // save register values on stack to be safe
push ecx
movsx ecx,temp_char // enregister the source character
movsx eax,EKey // and encryption key.
call encryptB // calls the encryption subroutingencrypt the character
mov temp_char,al // only need lower byte of EAX to return encrypted char
pop ecx // restore original register values from stack
pop eax
}
EChars [i] = temp_char; // Store encrypted char in the encrypted chars array
}
return;
encryption routine ASM
__asm {
encryptB: push edx //saves register value edx on stack
push ecx //saves register value ecx on stack
not eax //
add eax,0x04 //add 4 to eax register
mov edx,eax //move eax to edx
pop eax //brings eax back to
xor eax,edx //clear values to zero
pop edx //bring edx back
rol al,3 //three times.
sub al,0x02 //subtracts 2 from al
ret
}
Here ends the encryption part
The decryption routine will start as follows
void decrypt_chars (int length, char EKey){
char temp_char;
for (int i = 0; i < length; i++){
temp_char = EChars [i];
__asm {
}
DChars [i] = temp_char;
}
return;
decryption routine ASM
__asm {
}