'Crypt the block of data through DES bit-manipulation'

def __des_crypt(self, block, crypt_type):

    block = self.__permutate(des.__ip, block)
    self.L = block[:32]
    self.R = block[32:]
    if (crypt_type == des.ENCRYPT):
        iteration = 0
        iteration_adjustment = 1
    else:
        iteration = 15
        iteration_adjustment = (-1)
    i = 0
    while (i < 16):
        tempR = self.R[:]
        self.R = self.__permutate(des.__expansion_table, self.R)
        self.R = list(map((lambda x, y: (x ^ y)), self.R, self.Kn[iteration]))
        B = [self.R[:6], self.R[6:12], self.R[12:18], self.R[18:24], self.R[24:30], self.R[30:36], self.R[36:42], self.R[42:]]
        j = 0
        Bn = ([0] * 32)
        pos = 0
        while (j < 8):
            m = ((B[j][0] << 1) + B[j][5])
            n = ((((B[j][1] << 3) + (B[j][2] << 2)) + (B[j][3] << 1)) + B[j][4])
            v = des.__sbox[j][((m << 4) + n)]
            Bn[pos] = ((v & 8) >> 3)
            Bn[(pos + 1)] = ((v & 4) >> 2)
            Bn[(pos + 2)] = ((v & 2) >> 1)
            Bn[(pos + 3)] = (v & 1)
            pos += 4
            j += 1
        self.R = self.__permutate(des.__p, Bn)
        self.R = list(map((lambda x, y: (x ^ y)), self.R, self.L))
        self.L = tempR
        i += 1
        iteration += iteration_adjustment
    self.final = self.__permutate(des.__fp, (self.R + self.L))
    return self.final
