Filter löschen
Filter löschen

matlab code for pseudo random

4 Ansichten (letzte 30 Tage)
marie lasz
marie lasz am 8 Dez. 2020
Kommentiert: Rik am 8 Dez. 2020
hello,
Maybe I am asking a very dumb question here but I would like to confirm if I am thinking it right or not. this code is generating some pseudo random noise (please correct me if I am wrong) , so the question is what is this _key.bmp image file , I mean any grayscale image can I read here? I know by this file we are actually generating a key here, so what can be alternate solution here maybe?
% read in key for PN generator
file_name='_key.bmp';
key=double(imread(file_name))./256;
% reset MATLAB's PN generator to state "key"
rand('state',key);
% generate PN sequence
pn_sequence_zero=round(2*(rand(1,sum(sum(midband)))-0.5));

Antworten (1)

Rik
Rik am 8 Dez. 2020
This looks like a fairly fragile setup to share an encryption key.
Any file that results in a valid state value can be used. By setting the state you make the next calls to random functions return predictable output. So if I use the same state on my copy of the same release of Matlab I will get the same results as you.
  2 Kommentare
marie lasz
marie lasz am 8 Dez. 2020
so is it better to add any key rather than adding file and that key we can use in returning the same random sequence?
Rik
Rik am 8 Dez. 2020
The file is the key. My point is only that you are relying on the random number generator being the exact same between two users. If you're only using it for an example that would be fine, but if you're actually using it for something important you should either use a completely different setup, or make sure you're using the exact same release-update combination.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Images finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by