GNU Octave 维度不匹配错误?
GNU Octave dimensions mismatch error?
我在 GNU Octave 上出错了。
error: sim_encryption: A(I,J,...) = X: dimensions mismatch
error: called from
sim_encryption at line 11 column 13
Line 11 is " s( 1 , : ) = mod( s + k , 2 ) ;" .
我搜索error的时候说是matrix的问题,但是matrix看起来并没有什么不同。那么问题是什么?
ph = '3243f6a8885a308d313198a2e0370734' ;
kh = '2b7e151628aed2a6abf7158809cf4f3c' ;
k = zeros( 11 , 128 ) ;
r = zeros( 11 , 8 ) ;
s = zeros( 11 , 128 ) ;
s( 1 , : ) = hex_to_bin( ph ) ;
k( 1 , : ) = hex_to_bin( kh ) ;
r( 1 , : ) = [ 0 0 0 0 0 0 0 1 ] ;
s( 1 , : ) = mod( s + k , 2 ) ;
for i = 1 : 10 ,
i ;
[ k( i+1 , : ) , r( i+1 , : ) ] = key_schedule( k( i , : ) , r( i , : ) ) ;
s( i+1 , : ) = mod( k( i+1 , : ) + aes_round( s( i , : ) , i ) , 2 ) ;
kh = bin_to_hex( k(i+1,:) , 32 ) ;
sh = bin_to_hex( s(i+1,:) , 32 ) ;
end
ch = bin_to_hex( s(11,:) , 32 )
由于 s
和 k
的大小都是 11 x 128,因此结果
mod(s + k, 2)
也是 11 x 128,您正试图覆盖 s(1,:)
,即 1 x 128
我在 GNU Octave 上出错了。
error: sim_encryption: A(I,J,...) = X: dimensions mismatch
error: called from
sim_encryption at line 11 column 13
Line 11 is " s( 1 , : ) = mod( s + k , 2 ) ;" .
我搜索error的时候说是matrix的问题,但是matrix看起来并没有什么不同。那么问题是什么?
ph = '3243f6a8885a308d313198a2e0370734' ;
kh = '2b7e151628aed2a6abf7158809cf4f3c' ;
k = zeros( 11 , 128 ) ;
r = zeros( 11 , 8 ) ;
s = zeros( 11 , 128 ) ;
s( 1 , : ) = hex_to_bin( ph ) ;
k( 1 , : ) = hex_to_bin( kh ) ;
r( 1 , : ) = [ 0 0 0 0 0 0 0 1 ] ;
s( 1 , : ) = mod( s + k , 2 ) ;
for i = 1 : 10 ,
i ;
[ k( i+1 , : ) , r( i+1 , : ) ] = key_schedule( k( i , : ) , r( i , : ) ) ;
s( i+1 , : ) = mod( k( i+1 , : ) + aes_round( s( i , : ) , i ) , 2 ) ;
kh = bin_to_hex( k(i+1,:) , 32 ) ;
sh = bin_to_hex( s(i+1,:) , 32 ) ;
end
ch = bin_to_hex( s(11,:) , 32 )
由于 s
和 k
的大小都是 11 x 128,因此结果
mod(s + k, 2)
也是 11 x 128,您正试图覆盖 s(1,:)
,即 1 x 128