[Solved] C++ encryption and decryption [closed]


Answer:

In order to do the opposite of your encryption operation, you should replace the call to encrypt_nn with a new routine that decrements instead of increments:

 __asm {

    decrypt_nn:
        mov eax, ecx        
            dec eax 
            ret
    }

Comment:

You have changed the loop statement from

for (int i = 0; i < length; i++)  

to

for (int i = 0; i < length; i--)  

In the first case, loop will iterate through all values between 0 and length-1. This means you will iterate through your arrays of chars (assuming length is its size).

In the second case, you will get unpredictable behavior, since you are testing for i < length but doing i-- in each loop iteration.
See more information here.

2

solved C++ encryption and decryption [closed]