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

조회 수: 1 (최근 30일)
Md. Atiqur Rahman
Md. Atiqur Rahman 2022년 8월 22일
편집: Md. Atiqur Rahman 2022년 8월 22일
% 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)

답변 (1개)

the cyclist
the cyclist 2022년 8월 22일
편집: the cyclist 2022년 8월 22일
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
Md. Atiqur Rahman
Md. Atiqur Rahman 2022년 8월 22일
편집: Md. Atiqur Rahman 2022년 8월 22일
thanks for fast reply. But, I need different "In" on every stage and key in each stage would be ciphertext of previous stage

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Composite Components에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by