@Farah Izzati: this is not twitter, so I removed the ugly # symbol from your tags, and split them correctly into separate tags. Next time you can do this yourself: simply enter each tag as words, and place a comma to separate the tags. Simple.
How to xor key with the element by element in an array?
    5 ビュー (過去 30 日間)
  
       古いコメントを表示
    
hi, Currently i'am doing image encryption for my project. Basically what i want to do is.. XOR key with the first element(done). The answer would XOR with the 2nd element. Next answer will be XOR with the 3rd element and so on. (It is similar to cumsum but i want to do it using XOR)
This is my code..
key = bitxor(bin2dec(strAscii), bitt(1,1))
for r = 1:rw
  for c = 1:cl
    xored = bitxor(key,bitt(r:-1:c))
  end     
end
and the output is xored =
1×0 empty uint8 row vector
I hope somebody could share with me how to do this. because i have been stuck for few days to figure out this.
回答 (1 件)
  Shounak Shastri
      
 2018 年 4 月 24 日
        Here, try this
 I = randi([1,10],5);          %Input matrix
 [m, n] = size(I)              %Size of the input matrix for looping
 key = randi([1,10]);          %Key
 I = uint8(I);                 %Making sure the key and the input matrix have same number of bits
 key = uint8(key);
 for ii = 1 : m
   for jj=  1 : n
      c(ii, jj) = bitxor(key, I(ii,jj));
      key = c(ii, jj);          %Storing the encrypted value as the new key
    end
 end
This is just a suggestion. This code could probably be optimized.
Best of Luck.
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


