Advertisement
onexiv

jaws

Feb 23rd, 2024
1,084
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.86 KB | None | 0 0
  1. def iterate_bits(input, step):
  2.     # Assuming input is a 64-bit integer
  3.     print(bin(input))
  4.     parts = []
  5.     iterations = 0
  6.     while input:
  7.         parts.append(bin(input & ((1 << step) - 1)))  # Print the last 'step' bits
  8.         input >>= step + 1 # Shift 'step' bits to the right
  9.         step = (step % 64) + 1  # Increase step size, but keep it within 1-64
  10.         iterations += 1
  11.     return parts
  12.  
  13. def reverse_iterate_bits(bit_groups, steps):
  14.     output = 0
  15.     for bits, step in zip(bit_groups[::-1], steps[::-1]):
  16.         output <<= step + 2
  17.         output |= int(bits[2:], 2)
  18.     return output
  19.  
  20. # Test the function
  21. steps = [1, 2, 3, 4, 5, 6, 7, 8, 9]
  22.  
  23. # Test the function
  24. print(bin(1099011607776*256**2+5767))
  25. parts = iterate_bits(1099011607776*256**2+5767, 4)
  26. print(parts)
  27. output = reverse_iterate_bits(parts, steps)
  28.  
  29. print(bin(output))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement