I recently work on an algorithm that encrypt some data with 8 byte length. I worked hard and I successful to get this algorithm, but I need decryption of this algorithm. How I can invert it?
I guess this is a hash algorithm and I can't invert it. but I want to make sure about that.
int tmp1 = 0;
int tmp2 = 0;
unsigned short int _array_1[8]={0};
unsigned short int _array_out[8]={0};
for(int j = 0 ; j <5; j++)
tmp1 = tmp1 * 0x40 + _array_1[j];
for(int j = 5; j<8; j++)
tmp2 = (tmp2 << 5) + _array_1[j];
for (int j = 0 ; j<4; j++)
_array_1[j] = (tmp1 >> 8*j ) & 0xFFFF ;
for (int j = 4 ; j<6; j++)
_array_1[j] = (tmp2 >> 8*(j-4) ) & 0xFFFF ;
_array_1[6] = 0;
_array_1[7] = 0;
_array_out [0] = (get_diff (_array_1[1],0x1A)) * (get_diff (_array_1[4],0x9C));
_array_out [1] = (get_diff (_array_1[1],0x9C)) * (get_diff (_array_1[4],0x2E));
_array_out [2] = (get_diff (_array_1[5],0x1A)) * (get_diff (_array_1[2],0x9C));
_array_out [3] = (get_diff (_array_1[5],0x9C)) * (get_diff (_array_1[2],0x2E));
_array_out [4] = (get_diff (_array_1[3],0x1A)) * (get_diff (_array_1[0],0x9C));
_array_out [5] = (get_diff (_array_1[3],0x9C)) * (get_diff (_array_1[0],0x2E));
And
uint8_t get_diff(uint8_t a, uint8_t b)
{
uint8_t result =0;
result = (a> b )? (a-b) : (b-a);
return result;
}
Edited:
According to the lan comment I edited my question and some data such as tmp1 and tmp2 added.
Also, I will present an example as instance.
Example
Input = 0x01, 0x05, 0x00, 0x0C, 0x1B, 0x14, 0x18, 0x1A
Output = 0xAE, 0xF4, 0x48, 0x6A, 0x99, 0x81
Thanks.