Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def iterate_bits(input, step):
- # Assuming input is a 64-bit integer
- print(bin(input))
- parts = []
- iterations = 0
- while input:
- parts.append(bin(input & ((1 << step) - 1))) # Print the last 'step' bits
- input >>= step + 1 # Shift 'step' bits to the right
- step = (step % 64) + 1 # Increase step size, but keep it within 1-64
- iterations += 1
- return parts
- def reverse_iterate_bits(bit_groups, steps):
- output = 0
- for bits, step in zip(bit_groups[::-1], steps[::-1]):
- output <<= step + 2
- output |= int(bits[2:], 2)
- return output
- # Test the function
- steps = [1, 2, 3, 4, 5, 6, 7, 8, 9]
- # Test the function
- print(bin(1099011607776*256**2+5767))
- parts = iterate_bits(1099011607776*256**2+5767, 4)
- print(parts)
- output = reverse_iterate_bits(parts, steps)
- print(bin(output))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement