I am using DES algorithm and I need to split std::bitset<56> permutationKeyinto two halves.
std::bitset<56> permutationKey(0x133457799BBCDF);
std::bitset<28> leftKey;
std::bitset<28> rightKey;
std::bitset<56> divider(0b00000000000000000000000000001111111111111111111111111111);
rightKey = permutationKey & divider;
leftKey = (permutationKey >> 28) & divider;
I tried using bitset<56>for bitset<28>, but that did not work.
Another way to achieve the same thing is to loop over and assign each bit separately. I want to achieve this without using loops, there must be another way.
I was able to do this with primitive types
uint64_t key = 0b0001010101010101110110001100001110000011111100000000011111000000;
uint32_t right = (uint32_t)key;
uint32_t left = key >> 32;
How can I split bitsetas follows?
source
share