58,50,42,34,26, 18, 10,2,60,52,44,36,28,20, 12,4,
62,54,46,38,30,22, 14,6,64,56,48,40,32,24, 16,8,
57,49,4 1,33,25, 17,9, 1,59,5 1,43,35,27, 19, 1 1,3,
6 1,53,45,37,29,2 1, 13,5,63,55,47,39,3 1,23, 15,7,
That is to say, the 58th bit of the input is changed to the first bit, the 50th bit is changed to the second bit, ..., and so on, and the last bit is the original 7th bit. L0 and R0 are the two parts of the transposed output, for example, L0 is the left 32 bits of the output and R0 is the right 32 bits.
For example, if the input value before replacement is set to d 1d2d3...d64, the result after initial replacement is: l0 = d58d50...D8;; R0=D57D49...D7 .
Its typical C code implementation is as follows:
Define the IP substitution table shown in the above table, an array of type char, with a length of 64;
Then, in the period from 0 to 64, according to the contents of the IP replacement table, the data of the source array is filled into the destination array, that is, IP replacement is realized;
//initial arrangement (IP)
const static char IP_Table[64] = {
58, 50, 42, 34, 26, 18, 10, 2, 60, 52, 44, 36, 28, 20, 12, 4,
62, 54, 46, 38, 30, 22, 14, 6, 64, 56, 48, 40, 32, 24, 16, 8,
57, 49, 4 1, 33, 25, 17, 9, 1, 59, 5 1, 43, 35, 27, 19, 1 1, 3,
6 1, 53, 45, 37, 29, 2 1, 13, 5, 63, 55, 47, 39, 3 1, 23, 15, 7
};
void DES _ InitialPermuteData(char * src,char* dst)
{
//IP
int I = 0;
for(I = 0; I & lt64; i++)
{
dst[I]= src[IP _ Table[I]- 1];
}
}