def two_key_encryption(im_arr, x_size, y_size, k1, k2): size = x_size * y_size permut = utils.two_kdp(size, k1, k2) temp_hold = [] for x in range(x_size): temp_hold.append([]) for y in range(y_size): temp_hold[x].append(im_arr[x, y]) for x in range(x_size): for y in range(y_size): p_index = permut[x * y_size + y] p_x_index = p_index / y_size p_y_index = p_index - (p_x_index * y_size) im_arr[x, y] = temp_hold[p_x_index][p_y_index] pass
def two_key_encryption(im_arr, x_size, y_size, k1, k2): size = x_size*y_size permut = utils.two_kdp(size, k1, k2) temp_hold = [] for x in range(x_size): temp_hold.append([]) for y in range(y_size): temp_hold[x].append(im_arr[x, y]) for x in range(x_size): for y in range(y_size): p_index = permut[x*y_size + y] p_x_index = p_index / y_size p_y_index = p_index - (p_x_index * y_size) im_arr[x, y] = temp_hold[p_x_index][p_y_index] pass
def two_key_decryption(im_arr, x_size, y_size, k1, k2): size = x_size * y_size permut = utils.two_kdp(size, k1, k2) for p in permut: if type(p) is not int: print p assert False temp_hold = [] for x in range(x_size): temp_hold.append([]) for y in range(y_size): temp_hold[x].append(im_arr[x, y]) for x in range(x_size): for y in range(y_size): p_index = permut[x * y_size + y] p_x_index = p_index / y_size p_y_index = p_index - (p_x_index * y_size) im_arr[p_x_index, p_y_index] = temp_hold[x][y] pass
def two_key_decryption(im_arr, x_size, y_size, k1, k2): size = x_size*y_size permut = utils.two_kdp(size, k1, k2) for p in permut: if type(p) is not int: print p assert False temp_hold = [] for x in range(x_size): temp_hold.append([]) for y in range(y_size): temp_hold[x].append(im_arr[x, y]) for x in range(x_size): for y in range(y_size): p_index = permut[x*y_size + y] p_x_index = p_index / y_size p_y_index = p_index - (p_x_index * y_size) im_arr[p_x_index, p_y_index] = temp_hold[x][y] pass