Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7982521
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T10:41:58+00:00 2026-06-04T10:41:58+00:00

I was given some code a few weeks ago as part of an application

  • 0

I was given some code a few weeks ago as part of an application to an encryption job I was interested in. They sent me a code and basically wanted to see if I understood it and could improve it.

I tried my best but all the code was brand new to me and I couldn’t figure out what it did. I eventually gave it up as a lost cause as I had other things to do. However, I’m still very interested in learning about it, just for knowledge sake. Can anyone help me learn more about this type of programming or what specifically this does?

I’ll try to cut it down and give my impressions.

This is the part that does the actual encryption; from what I could figure out, using an XOR encryption. Is this correct? I also believe input_2 and input_1 are erroneously switched.

typedef int int32;
typedef char int8;

void change_it(int8 *output, int8 *input_1, const int8 *input_2, int32 length)
{
    int32 i = 0;

    for(i=0; i<length; i++)
    {
        output[i] = (int8)(input_1[i] ^ input_2[i]);
    }
    return;
}

Here they overloaded an itoa to make the string into either decimal or a hex digit, although for what purpose I’m unsure.

void itoa( int32 num, int8  *alpha, int32 radix )
{
    if( radix == 10 )
    {
        sprintf(alpha, "%i", num);
    }
    else if( radix == 16 )
    {
        sprintf(alpha, "%X", num);
    }
}

This is the main running function that main calls. It does some weird bitwise stuff and then calls change_it 4 times. This was the part that mostly stumped me.

int8 *modify_it(int32 modifier, const int8  *input_1, int32 length)
{
    int8  leading[3];
    int32 i_leading;
    int8 * temp_string = NULL;
    int8 * ret;
    int32 i = 0;

    itoa(modifier/2, leading, 10);
    i_leading = atoi(leading);

    temp_string = (int8 *) malloc(8);
    ret = (int8 *) malloc(length);
    memset(temp_string, 0, 8);
    temp_string[0] = 0;

    if( (modifier+1)%2 == 0 ) {
        temp_string[0] = (int8)((i_leading<<4) + 8);
    }
    else {
        temp_string[0] = (int8)(i_leading<<4);
    }

    for(i=0; i<(length>>3); i++)
    {
        change_it(ret+i*8, temp_string, input_1+i*8, 8);
    }
    free(temp_string);

    return ret;
}

Last, but never least, the main function to start it off.

int main(int argc, char **argv) {

    int8 data[32];
    memset(data, 0x0A, sizeof(data));

    int8 *resp = modify_it(0xFF, data, sizeof(data));

    free(resp);
    system("PAUSE");
    return 0;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T10:41:59+00:00Added an answer on June 4, 2026 at 10:41 am

    What this does, basically, is – for back of a better term – obfuscate the input.

    This is a very amateurish attempt by someone that will fail pretty badly at both securing and storing data.

    There are many errors like clearing an array (which could’ve been done during the allocation with calloc) and then ‘making sure’ it is cleared again by clearing part of it ‘manually’. There are so many, many things wrong with this it makes me want to both puke and laugh.

    If this is not homework, throw it away. Do not try to learn from it. There is nothing that is correct or good about this code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

A few weeks ago I wrote an SNMP relayer for our ops group. They
I have been given some matlab code compiled using the .net compiler. I can
I have been given some generated code which looks like so: <form id=form1 method=post
Given: code inside a stored proc: select bleh into #tblTemp from FunctionThatReturnsTable('some','params') -- do
I have an Excel Workbook which has some VSTO-based c# code. Given a known
In some sample code given by a professor: #include <stdio.h> #include <string.h> #include <stdlib.h>
Few weeks ago I asked a question on increasing the speed of a function
A few weeks ago i asked a question about a multilanguage site (see Multilanguage
Can someone give me some code to set the cell of an excel spreadsheet
I've been give some lovely Java code that has a lot of things like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.