Assembly code. Encryption to Decryption Routine -


  • could take @ me , me work out decryption reverse string has been input user. don't mean doing reverse of procedure.

      push edx    push ecx    not eax    add eax,0x04    mov edx,eax    pop eax    xor eax,edx    pop edx    rol al,1    rol al,1   rol al,1    sub al,0x02    ret 

    *

the registers are: inwards- ecx: encryption key. eax: character encrypted.

outwards- eax: encrypted character

thank taking time look.

the algorithm symmetric because decrypt every character , key combination.

these 2 functions tested loop error in decrypting value back:

#include <iostream> using namespace std;  unsigned char enc(unsigned char ch, unsigned char key) {     unsigned char tmp = key^(~ch+(unsigned char)0x04);     return (( (tmp<<3) | (tmp>>5) ) & 0xff)-0x02; }  unsigned char dec(unsigned char ch, unsigned char key) {     unsigned char tmp = (ch+0x02);     tmp = ((tmp>>3) | (tmp<<5)) & 0xff;     return ~((tmp^key )-(unsigned char)0x04); }  int main() {     // single encryption test     char c = 'a';     char key = 'k';     cout << "single test:" << (char)enc(c, key) << endl;      bool problem = false;     int k, ch;     for(k=0;k<256;k++)     {          for(ch=0;ch<256;ch++)         {             if( enc( dec((unsigned char)ch, (unsigned char)k), k) != ch )             {                 problem = true;                 cout << "error k=" << k << "c=" << ch                      << "result=" <<  (unsigned int)enc( dec((unsigned char)ch, (unsigned char)key), (unsigned char)key) << endl;              }         }     }     if(problem) cout << "there problem." << endl;     else cout << "there no problem." << endl; } 

Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

java - More than one row with the given identifier was found: 1, for class: com.model.Diagnosis -