0

我正在通过在 Galois 字段 16 (2^16) 上运行的 Reed Solomon 编码器传递一个密钥(长度为 16 个 ASCII 字符 = 128 位)。

我的问题是:这个密钥应该被视为 128 位还是 256 位?

我在这里迷路了,因为我知道 ASCII 字符 = 8 位,所以 16 个 ASCII 字符 = 128 位。

我读过一篇文章,它说一旦你通过 GF(16) 传递密钥,那么它将是 256,而不是 128,我应该只传递一个带有 8 个 ASCII 字符的密钥。这个对吗?请参阅下面我使用的函数,其中我使用了 Matlab 通信工具箱函数 code = errorCorrectingCode(data, LENGTH) % ERRORCORRECTINGCODE 获取输入数据并通过 Reed-Solomon Code 运行它 % 请参见以下链接: % http://www. mathworks.com/help/comm/ref/encode.html % >>> 示例:rsdec(rsenc(gf([1 2 3 ; 4 5 6],3),7,3),7,3);

% Apply Reed-Solomon encoding operation to data to obtain ECCed code.

% convert to GF(2^16) elements:
% (two characters map to one element, so 16char = 8)
elements = keyToField(data);
msg = elements';

% create encoding:
code = rsenc(msg,LENGTH,length(msg));

结尾

function gfArray = keyToField(keystr)
% KEYTOFIELD takes a key string composed of N characters,
% converting every two characters to a field array in the
% field GF(2^16).

% define number of elements in gfArray as floor(N / 2):
numElts = floor(length(keystr) / 2);
% define flag that checks if keystr is odd or not:
oddLength = mod(length(keystr),2);

% initialize pre-output:
gfArray_bin = zeros((numElts + oddLength),16);

% loop thru pairs of chars in the key:
for idx=1:numElts
curr = 2 * idx;
gfArray_bin(idx,:) = [dec2bin(double(keystr(curr - 1)),8)       dec2bin(double(keystr(curr)),8)] - 48;
end

% take care of last element if odd:
if (oddLength)
gfArray_bin(end,:) = dec2bin(double(keystr(end)),16) - 48;
end

% convert everything to decimal again:
gfArray_dec = zeros(size(gfArray_bin,1),1);
for jdx=1:size(gfArray_bin,1)
% shorthand for current row:
bitrow = gfArray_bin(jdx,:);
% convert from a row of 1's and 0's to decimal representation:
gfArray_dec(jdx) = sum(bitrow .* 2.^(numel(bitrow)-1:-1:0));
end

% generate output by wrapping gfArray_dec in field array:
gfArray = gf(gfArray_dec,16);

end
4

0 回答 0