0
点赞
收藏
分享

微信扫一扫

AES/DES加解密的matlab源码

圣杰 2022-10-10 阅读 145


% Set 1 data

a{1,1} = 'Alice';

a{1,2} = 'alice123';

a{2,1} = 'Bob';

a{2,2} = 'Bob123';

a{1,3} = [1 1 0 0];

a{2,3} = [1 1 0 0 1 0];

a

%Convert to uint8 format and encrypt

[row col] = size(a);

for i=1:row

    for j=1:col

        if ~ischar(a{i,j})|~isa(a{i,j},'uint8')

            uint8_a = uint8(a{i,j});

            encry_op{i,j} = aescrypt(uint8_a,'test1234');

        else

            encry_op{i,j} = aescrypt(a{i,j},'test1234');

        end

    end

end

encry_op

% uint8_reshape_a = uint8(reshape_a)

%Decryption

[row col] = size(encry_op);

for i=1:row

    for j=1:col

        decry_op{i,j} = aesdecrypt(encry_op{i,j},'test1234');

    end

end

decry_op

%Reconstruct

reconstruct_op = decry_op;

for i=1:row

    for j=1:2

        reconstruct_op{i,j}=char(decry_op{i,j});

    end

end

reconstruct_op

举报

相关推荐

0 条评论