【图像加密】基于低对称密码算法实现图像加密解密附matlab代码

编程入门 行业动态 更新时间:2024-10-10 23:22:38

【<a href=https://www.elefans.com/category/jswz/34/1771430.html style=图像加密】基于低对称密码算法实现图像加密解密附matlab代码"/>

【图像加密】基于低对称密码算法实现图像加密解密附matlab代码

✅作者简介:热爱科研的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.

⛳️ 代码获取关注我

❤️部分理论引用网络文献,若有侵权联系博主删除
❤️ 关注我领取海量matlab电子书和数学建模资料

🍅 仿真咨询

1.卷积神经网络(CNN)、LSTM、支持向量机(SVM)、最小二乘支持向量机(LSSVM)、极限学习机(ELM)、核极限学习机(KELM)、BP、RBF、宽度学习、DBN、RF、RBF、DELM实现风电预测、光伏预测、电池寿命预测、辐射源识别、交通流预测、负荷预测、股价预测、PM2.5浓度预测、电池健康状态预测、水体光学参数反演、NLOS信号识别、地铁停车精准预测、变压器故障诊断
2.图像识别、图像分割、图像检测、图像隐藏、图像配准、图像拼接、图像融合、图像增强、图像压缩感知
3.旅行商问题(TSP)、车辆路径问题(VRP、MVRP、CVRP、VRPTW等)、无人机三维路径规划、无人机协同、无人机编队、机器人路径规划、栅格地图路径规划、多式联运运输问题、车辆协同无人机路径规划
4.无人机路径规划、无人机控制、无人机编队、无人机协同、无人机任务分配
5.传感器部署优化、通信协议优化、路由优化、目标定位
6.信号识别、信号加密、信号去噪、信号增强、雷达信号处理、信号水印嵌入提取、肌电信号、脑电信号
7.生产调度、经济调度、装配线调度、充电优化、车间调度、发车优化、水库调度、三维装箱、物流选址、货位优化
8.微电网优化、无功优化、配电网重构、储能配置
9.元胞自动机交通流 人群疏散 病毒扩散 晶体生长

更多推荐

【图像加密】基于低对称密码算法实现图像加密解密附matlab代码

本文发布于:2024-03-14 14:48:31,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1736708.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:图像   对称   算法   密码   加密解密

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!