Skip to content
View in the app

A better way to browse. Learn more.

ResHax

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.
Help us keep the site running.

Coding help :D

Featured Replies

  • Author
  • Localization

Ekey, posted Tue Jul 07, 2020 3:04 pm (57483)


Hey guys. I have a specific project for which it is necessary to encrypt some files back after decryption. The algorithm is simple (XOR) and I was hoping that it would work both ways (decrypt and encrypt data) but the function works as it turned out only in one direction - decrypt only. I need expert help and teach the function to correctly encrypt data back :)


Code:
uint8_t kBox1[20] = {
   0xEB, 0x57, 0x50, 0x86, 0x32, 0x0D, 0x27, 0x60, 0xF4, 0xDE,
   0xF2, 0x4F, 0x6F, 0x13, 0xDA, 0x7B, 0x29, 0x3F, 0xF1, 0x41};

uint8_t kBox2[20] = {
   0x2D, 0x50, 0xD7, 0x64, 0x17, 0xAB, 0x25, 0x0B, 0xC0, 0x3E,
   0x61, 0x49, 0x20, 0x7A, 0x8E, 0x78, 0xA0, 0x67, 0x8D, 0x29};
   
uint32_t Var4 = 0;
int32_t Var8 = (kBox2[16] * kBox1[12]) * dwSize;

for(int32_t i = 0; i {
    uint32_t j = int32_t(Var8 & (Var4 > (kBox2[19-(i % 20)] % 7);
    lpBuffer[i] ^= kBox1[j % 20] ^ (j j / 255) ^ kBox2[i % 20];
    Var4 = dwSize;
}


Files for testing are attached. I will be glad to any help and advice.

Thanks in advance :)
  • Author
  • Localization

aluigi, posted Tue Jul 07, 2020 9:44 pm (57495)


The function works with both encryption and decryption, it's the same.

The only difference is that the encrypted file has an additional footer at the end "TGCA\x14\x10\x06\x15" so when you decrypt it you must remove the 8 bytes from dwSize.
  • Author
  • Localization

Ekey, posted Wed Jul 08, 2020 9:55 am (57503)


Thanks Luigi for answer.

Unfortunately, I already tried to encrypt but the data is different, except for the 1st byte. In addition, the encrypted file is not decrypted by this function - the output data is like garbage :)

Comparison:

First 0x200 bytes of original:

Image

And first 0x200 of new file

Image

Therefore, I wonder what could be the solution :)
  • Author
  • Localization

Ekey, posted Wed Jul 08, 2020 10:11 am (57504)


Ah, i'm idiot :lol:
Guest
This topic is now closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.