Problem with RC5 Image encryption
정보
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
이전 댓글 표시
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
댓글 수: 0
답변 (1개)
Jan
2021년 11월 18일
0 개 추천
For images, "plain text" means the sequence of bytes. Import the image file by fopen&fread(fid, Inf, '*uint8'), not by imread().
댓글 수: 3
Muhammad Abdulrazek
2021년 11월 18일
Jan
2021년 11월 18일
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
2021년 11월 18일
이 질문은 마감되었습니다.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
