I need code for image encryption using Rc4

回答 (2 件)

kareem ahmed
kareem ahmed 2018 年 5 月 6 日
編集済み: Image Analyst 2018 年 5 月 7 日

0 投票

It is a link to full project developed by me to implement RC4 in matlab

https://www.youtube.com/watch?v=qy7mUyTlelY

17 件のコメント

sajjad leith
sajjad leith 2021 年 5 月 12 日
this code for encrypt text not image
Walter Roberson
Walter Roberson 2021 年 5 月 12 日
If you read an image as uint8 and then you char() the uint8 then the result will be text that the algorithm could be applied to.
Mohammed Ali
Mohammed Ali 2022 年 1 月 22 日
Walter roberson how i can do that?
Walter Roberson
Walter Roberson 2022 年 1 月 22 日
img = imread('flamingos.jpg');
S = char(reshape(img, 1,[]));
encrypted = kareems_RC4(S);
Mohammed Ali
Mohammed Ali 2022 年 1 月 22 日
where to put it ?
KSA or
main_script
PRGA
and sorry
Walter Roberson
Walter Roberson 2022 年 1 月 22 日
At 10 minutes into the video, the author is creating a new script and has just assigned
plaintext = 'Mission accomplished';
You would replace that with
img = imread('flamingos.jpg');
plaintext = char(reshape(img, 1,[]));
Mohammed Ali
Mohammed Ali 2022 年 1 月 26 日
Thanks so much I really appreciate it
Mohammed Ali
Mohammed Ali 2022 年 1 月 26 日
Sorry it doesn't work can you send the code in my email Mohamed1999dz@gmail.com
Walter Roberson
Walter Roberson 2022 年 1 月 26 日
In my country it would be illegal for me to send anyone encryption code unless I knew for a fact that they were physically present in my country.
Mohammed Ali
Mohammed Ali 2022 年 1 月 26 日
編集済み: Mohammed Ali 2022 年 1 月 26 日
Ah ok When i did what you tell me img = imread('flamingos.jpg'); plaintext = char(reshape(img, 1,[])); I did get error in the commond img=imread('flamingos.jpg');
Mohammed Ali
Mohammed Ali 2022 年 1 月 26 日
key = 'KAREEM';
img =imread('Flamingos.jpg');
plaintext = char(reshape(img, 1,[]));
Z = uint8(PRGA(KSA(key), size(plaintext,2)));
P = uint8(char(plaintext));
res = bitxor(Z, P);
%printing result in hex and unicode
res_in_hex = mat2str(dec2hex(res,2))
res_in_unicode = char(res)
it said error in img
Walter Roberson
Walter Roberson 2022 年 1 月 26 日
flamingos.jpg is supplied with the Image Processing Toolbox. Replace flamingos.jpg with the name of the image you want to use.
Mohammed Ali
Mohammed Ali 2022 年 1 月 26 日
The same problem even when i choose another img
Mohammed Ali
Mohammed Ali 2022 年 1 月 26 日
What about decryption? How i can do that
Walter Roberson
Walter Roberson 2022 年 1 月 26 日
Note that file names might be case sensitive, depending on your configuration. 'Flamingos.jpg' might or might not work when the file name is 'flamingos.jpg'
Which MATLAB release are you using? Sufficiently old MATLAB did not have 'flamingos.jpg' . But 'cameraman.tif' should be present in quite old MATLAB.
I seem to recall that before about R2013a or so, that imread() needed the Image Processing Toolbox.
Walter Roberson
Walter Roberson 2022 年 1 月 26 日
What about decryption?
Sorry, I am not permitted to answer that question in more detail than "Call your decryption routine"
Once you have decrypted to a character vector then
bytes = uint8(decrypted_content);
filename = 'restored_image.tif';
[fid, msg] = fopen(filename, 'w');
if fid < 0; error('Could not open file "%s" for writing because "%s"', filename, msg); end
fwrite(fid, bytes, 'uint8');
fclose(fid)
The extension you use for filename should be the same as the original image file extension.
Mohammed Ali
Mohammed Ali 2022 年 1 月 27 日
Sorry for ask a lot of questions That's just because i have academic project And thank you so much for your help I use matlab 2013

サインインしてコメントする。

Saad Alzubaidi
Saad Alzubaidi 2022 年 6 月 14 日
編集済み: DGM 2022 年 6 月 14 日

0 投票

RC4 images encrypted code ... MATLAB (video walkthrough, 10 minutes)
https://youtu.be/-uoNW0AVuaQ

カテゴリ

ヘルプ センター および File ExchangeMATLAB Report Generator についてさらに検索

質問済み:

2017 年 1 月 2 日

編集済み:

DGM
2022 年 6 月 14 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by