Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int synchsafe(int in)
- {
- int out, mask = 0x7F;
- while (mask ^ 0x7FFFFFFF) {
- out = in & ~mask;
- out <<= 1;
- out |= in & mask;
- mask = ((mask + 1) << 8) - 1;
- in = out;
- }
- return out;
- }
- int unsynchsafe(int in)
- {
- int out = 0, mask = 0x7F000000;
- while (mask) {
- out >>= 1;
- out |= in & mask;
- mask >>= 8;
- }
- return out;
- }
- // Wikipedia Implementation
- // Source: https://en.wikipedia.org/wiki/Synchsafe
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement