Problem with RC5 Image encryption
Infos
Cette question est clôturée. Rouvrir pour modifier ou répondre.
Afficher commentaires plus anciens
Hello ,
I am working now on an image encryption script based on RC5 Encryption Algorithm
but i am little confused about how to read an image & convert it into an array of plain text & after decryption reconvert it into an image again
w = 32; %/* word size in bits */
r = 12; %/* number of rounds */
b = 16; %/* number of bytes in key */
c = 4; %/* number words in key = ceil(8*b/w)*/
t =26; %/* size of table S = 2*(r+1) words */
e=2.71828182846566; %Natural Logarithm
gr=1.61803398875; % Golden Ratio
ModParam=uint64(2^w);
P=uint64((e-2)*2^w); %Magic P Constant
Q=uint64((gr-2)*2^w+2^w); %Magic Q Constant
S=uint64(zeros(1,t)); %Sub-Key /Empty Variable
Original_Data=uint64(zeros(1,2)); %Empty Variable
K=uint64(ones(1,b)); %Key
original = imread('1.bmp');
Original_Data(1)=original(1); % Text block-1 to be encrypted
Original_Data(2)=original(2); % Text block-2 to be encrypted
S=RC5_Initialize(w,c,b,K,S,P,Q,t,ModParam);
CryptedText=RC5_Encrypt(S,r,w,Original_Data,ModParam);
DecryptedText=RC5_Decrypt(S,r,w,CryptedText,ModParam);

i will attach a .zip file which contains the script, functions & inputs
Thanks in Advance
Réponses (1)
Jan
le 18 Nov 2021
0 votes
For images, "plain text" means the sequence of bytes. Import the image file by fopen&fread(fid, Inf, '*uint8'), not by imread().
3 commentaires
Muhammad Abdulrazek
le 18 Nov 2021
Jan
le 18 Nov 2021
What do you want to do exactly: Encrypt a file, or the data of the image? For the 1st, use fopen&fread and fwrite. After decryption you have the image file again, which can be imported by imread. If you want to encrypt the image data only, import the data by imread. You can store them with imwrite also, or with fread, depending on how you want to access the encrypted data.
Muhammad Abdulrazek
le 18 Nov 2021
Cette question est clôturée.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
