code: def cipher (self, xl, xr, direction):
          
          if direction == self.ENCRYPT:
              for i in range (16):
                  xl = xl ^ self.p_boxes[i]
                  xr = self.__round_func (xl) ^ xr
                  xl, xr = xr, xl
              xl, xr = xr, xl
              xr = xr ^ self.p_boxes[16]
              xl = xl ^ self.p_boxes[17]
          else:
              for i in range (17, 1, -1):
                  xl = xl ^ self.p_boxes[i]
                  xr = self.__round_func (xl) ^ xr
                  xl, xr = xr, xl
              xl, xr = xr, xl
              xr = xr ^ self.p_boxes[1]
              xl = xl ^ self.p_boxes[0]
          return xl, xr
docs: Encryption primitive