✅作者简介:热爱科研的Matlab仿真开发者,修心和技术同步精进,matlab项目合作可私信。
🍎个人主页:Matlab科研工作室
🍊个人信条:格物致知。
更多Matlab仿真内容点击👇
⛄ 内容介绍
Since devices in the Wireless Sensor Network (WSN) are usually small in size, resource constraint is one of the critical issues that needs to be taken into consideration. In this paper, a low-complexity symmetric cryptographic algorithm, denoted as Secure Force (SF), is proposed. It is developed based on the Feistel structure, and the encryption part can be implemented by using a simple architecture that only consists of basic mathematical operations (AND, OR, XOR, XNOR, shifting, swapping). This can help to reduce the burden on encoder, because the more complex key expansion process is only carried out at the decoder. Besides confusion and diffusion of data, different substitution and permutation techniques are also included to complex the cipher. The proposed algorithm is also compared to several existing algorithms in terms of architecture, flexibility, and security.
⛄ 部分代码
% Performance Evaluation of Secure Force Symmetric Key Algorithm
% CCIS Springer 2015
%% Citation 2
% Ebrahim, Mansoor, and Chai Wai Chong.
% "Secure Force: A low-complexity cryptographic algorithm for Wireless Sensor Network (WSN)." Control System, Computing and Engi-neering (ICCSCE), 2013 IEEE International Conference on. IEEE, 2013.
clc
clear all
close all
tic
addpath subFunctions
% Data=imread('images\cameraman.tif');
% Data=imread('images\rice.tif');
% Data=imread('images\Lena.jpg');
% Data=imread('images\football.jpg');
Data=imread('images\onion.png');
% Data=imread('images\ORLFace.jpg');
[row,col,dim]=size(Data);
if (dim>1)
Data=rgb2gray(Data); % convert into grayscale if input image is a color image
end
%% Scalling and Convertion to binary
% Scalling to convert image into array of 8-pixels; each pixel is of 8 bits
% therefore 8 pixel will be equals to 64 bit of data
[Data,padding]=Scalling(Data,8);
Data_binary=convert2bin(Data);
%% Key Selection and Expansion
% Input the key in the form of 133457799bbcdff1
hex_key = '133457799bbcdff1';
[bin_key] = Hex2Bin( hex_key );
[K1,K2,K3,K4,K5]=SF_Key_Gen(bin_key);
%% Encryption and Decryption
orignal_msg=[];
encrypt_msg=[];
decrypt_msg=[];
for i=1:size(Data_binary,1)
orignal=Data_binary(i,:);
tic
[cipher]=SF_Encrypt(orignal,K1,K2,K3,K4,K5);
encryption_time(i)=toc;
[plaintext]=SF_Decryption(cipher,K1,K2,K3,K4,K5);
encrypt_msg(:,i)=Binary2Dec(cipher);
decrypt_msg(:,i)=Binary2Dec(plaintext);
end
if (padding~=0)
Data=reshape(Data,[size(Data,1)*size(Data,2) 1]);
Data=Data(1:end-padding);
encrypt_msg=reshape(encrypt_msg,[size(encrypt_msg,1)*size(encrypt_msg,2) 1]);
encrypt_msg=encrypt_msg(1:end-padding);
decrypt_msg=reshape(decrypt_msg,[size(decrypt_msg,1)*size(decrypt_msg,2) 1]);
decrypt_msg=decrypt_msg(1:end-padding);
end
%% Converting the Vectors into Images
Orignal=uint8(reshape(Data,[row,col]));
Encrypted=uint8(reshape(encrypt_msg,[row,col]));
Decrypted=uint8(reshape(decrypt_msg,[row,col]));
figure
subplot(1,3,1)
imshow(Orignal)
title('Orignal')
subplot(1,3,2)
imshow(Encrypted)
title('Encrypted')
subplot(1,3,3)
imshow(Decrypted)
title('Decrypted')
figure
subplot(2,1,1)
imhist(Orignal);
subplot(2,1,2)
imhist(Encrypted);
display('Done');
toc
%% Calculating the Encrypted and Orignal image's Entropy
Y=(imhist(Encrypted)+0.00001)/(row*col);
Y=-sum(Y.*log2(Y));
X=(imhist(Orignal)+0.00001)/(row*col);
X=-sum(X.*log2(X));
Re=[X Y]
⛄ 运行结果
⛄ 参考文献
Secure Force: A low-complexity cryptographic algorithm for Wireless Sensor Network (WSN)." Control System, Computing and Engi-neering (ICCSCE), 2013 IEEE International Conference on. IEEE, 2013.