function scytale_image_encryption_decryption()
img = imread('your_image.png');
[rows, cols, channels] = size(img);
total_pixels = rows * cols * channels;
encrypted_img_1d = scytale_encrypt(img_1d, key);
encrypted_img = reshape(encrypted_img_1d, [rows, cols, channels]);
imwrite(encrypted_img, 'encrypted_image.png');
decrypted_img_1d = scytale_decrypt(encrypted_img_1d, key);
decrypted_img = reshape(decrypted_img_1d, [rows, cols, channels]);
imwrite(decrypted_img, 'decrypted_image.png');
title('Encrypted Image');
title('Decrypted Image');
function encrypted = scytale_encrypt(data, key)
num_rows = ceil(length(data) / key);
padded_length = num_rows * key;
padded_data = [data; zeros(padded_length - length(data), 1)];
matrix = reshape(padded_data, [key, num_rows]);
encrypted_matrix = matrix';
encrypted = encrypted_matrix(:);
function decrypted = scytale_decrypt(data, key)
num_rows = ceil(length(data) / key);
encrypted_matrix = reshape(data, [num_rows, key]);
decrypted_matrix = encrypted_matrix';
decrypted = decrypted_matrix(:);
decrypted = decrypted(1:find(decrypted, 1, 'last'));