フィルターのクリア

How to solve the error in this code??

2 ビュー (過去 30 日間)
Darsana P M
Darsana P M 2017 年 11 月 8 日
コメント済み: Darsana P M 2017 年 11 月 9 日
x= {'d9' '31' '32' '25' 'f8' '84' '06' 'e5' 'a5' '59' '09' 'c5' 'af' 'f5' '26' '9a'};
y= {'fe' 'ff' 'e9' '92' '86' '65' '73' '1c' '6d' '6a' '8f' '94' '67' '30' '83' '08'};
X=hex2dec(x);
XX=dec2bin(X);
k=hex2dec(y);
u=aesinit(k);
w=aesencrypt(u,X);
U=dec2bin(w);
Xd = XX - '0'; % Convert CHAR '01' to DOUBLE [0, 1]
Ud = U - '0';
Result = [Ud(:, 1:end-1), xor(Xd, Ud(:, end))]
The error in the above code is:
Error using xor
Matrix dimensions must agree.
Error in counter1 (line 35)
Result = [Ud(:, 1:end-1), xor(Xd, Ud(:, end))]
I would like to find the xor of the encrypted value U and plaintext X??
  3 件のコメント
Darsana P M
Darsana P M 2017 年 11 月 8 日
aesinit(), it is actully a function for aes encryption.
Darsana P M
Darsana P M 2017 年 11 月 8 日
>> size(Xd)
ans =
16 8
Size of(Xd)

サインインしてコメントする。

採用された回答

per isakson
per isakson 2017 年 11 月 8 日
編集済み: per isakson 2017 年 11 月 9 日
The error is caused by
xor( Xd, Ud(:,end) )
The R2017b doc on xor says
Input arrays, specified as scalars, vectors, matrices, or multidimensional arrays.
Inputs A and B must either be the same size or have sizes that are compatible
(for example, A is an M-by-N matrix and B is a scalar or 1-by-N row vector). For
more information, see Compatible Array Sizes for Basic Operations.
Compatible Array Sizes for Basic Operations is rather new. There used to be scalar expansion and the function, bsxfun. Which release do you run?
Replacing the statement that causes the error by
xor( Xd, repmat(Ud(:,end),[1,size(Ud,2)]))
gives a result. However, I don't know whether it's the result you want.
  1 件のコメント
Darsana P M
Darsana P M 2017 年 11 月 9 日
Thanks a lot. This solved the problem. The problem was with the error used in XOR operation.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by