How can I create a 16 round for loop in this problem?

1 visualizzazione (ultimi 30 giorni)
% 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)

Risposte (1)

the cyclist
the cyclist il 22 Ago 2022
Modificato: the cyclist il 22 Ago 2022
Use a cell array to store the values:
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 Commento
Md. Atiqur Rahman
Md. Atiqur Rahman il 22 Ago 2022
Modificato: Md. Atiqur Rahman il 22 Ago 2022
thanks for fast reply. But, I need different "In" on every stage and key in each stage would be ciphertext of previous stage

Accedi per commentare.

Categorie

Scopri di più su Dictionaries in Help Center e File Exchange

Prodotti


Release

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by