How can I create a 16 round for loop in this problem?
Afficher commentaires plus anciens
% I need different "In" on every stage and key in each stage would be ciphertext of previous stage
clear all;
clc;
Key = randi([0,1],[1,4])
In1 = randi([0,1],[1,4])
Ciphertext1 = xor(Key,In1)
Key1 = Ciphertext1
In2 = randi([0,1],[1,4])
Ciphertext2 = xor(Key1,In2)
Key2 = Ciphertext2
In3 = randi([0,1],[1,4])
Ciphertext3 = xor(Key2,In3)
Key3 = Ciphertext3
In4 = randi([0,1],[1,4])
Ciphertext4 = xor(Key3,In4)
Key4 = Ciphertext4
In5 = randi([0,1],[1,4])
Ciphertext5 = xor(Key4,In5)
Key5 = Ciphertext5
In6 = randi([0,1],[1,4])
Ciphertext6 = xor(Key5,In6)
Key6 = Ciphertext6
In7 = randi([0,1],[1,4])
Ciphertext7 = xor(Key6,In7)
Key7 = Ciphertext7
In8 = randi([0,1],[1,4])
Ciphertext8 = xor(Key7,In8)
Key8 = Ciphertext8
In9 = randi([0,1],[1,4])
Ciphertext9 = xor(Key8,In9)
Key9 = Ciphertext9
In10 = randi([0,1],[1,4])
Ciphertext10 = xor(Key9,In10)
Key10 = Ciphertext10
In11 = randi([0,1],[1,4])
Ciphertext11 = xor(Key10,In11)
Key11 = Ciphertext11
In12 = randi([0,1],[1,4])
Ciphertext12 = xor(Key11,In12)
Key12 = Ciphertext12
In13 = randi([0,1],[1,4])
Ciphertext13 = xor(Key12,In13)
Key13 = Ciphertext13
In14 = randi([0,1],[1,4])
Ciphertext14 = xor(Key13,In14)
Key14 = Ciphertext14
In15 = randi([0,1],[1,4])
Ciphertext15 = xor(Key14,In15)
Key15 = Ciphertext15
In16 = randi([0,1],[1,4])
Ciphertext = xor(Key15,In16)
Réponses (1)
the cyclist
le 22 Août 2022
Modifié(e) : the cyclist
le 22 Août 2022
for k = 1:16
Key{k} = randi([0,1],[1,4]);
In{k} = randi([0,1],[1,4]);
Ciphertext{k} = xor(Key{k},In{k});
end
1 commentaire
Md. Atiqur Rahman
le 22 Août 2022
Modifié(e) : Md. Atiqur Rahman
le 22 Août 2022
Catégories
En savoir plus sur Creating and Concatenating Matrices dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!