-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDecryption.m
40 lines (32 loc) · 1.27 KB
/
Decryption.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
% Step 3: Decryption
%
% This script decrypts a ciphered image that has been hidden in another
% one.
%
% For this script to work you will need to write the following functions:
% ExtractImage, DecryptImage
%
% Author: Peter Bier
hiddenCipherFilename = input('Enter the filename for your hidden cipher image (or hit enter to use hiddenCipher.png):','s');
% Use the default name if one wasn't entered
if (length(hiddenCipherFilename) == 0)
hiddenCipherFilename = 'hiddenCipher.png'; % no name entered, so default to 'hiddenKey.png'
end
hiddenKeyFilename = input('Enter the filename for your hidden key image (or hit enter to use hiddenKey.png):','s');
% Use the default name if one wasn't entered
if (length(hiddenKeyFilename) == 0)
hiddenKeyFilename = 'hiddenKey.png'; % no name entered, so default to 'hiddenKey.png'
end
% Read in images and extract them
hiddenCipherImage = imread(hiddenCipherFilename);
hiddenKeyImage = imread(hiddenKeyFilename);
% Extract the hidden images
cipherImage = ExtractImage(hiddenCipherImage);
keyImage = ExtractImage(hiddenKeyImage);
% Decrypt the cipher image using the key
plainImage = DecryptImage(cipherImage,keyImage);
imwrite(plainImage,'plainImage.png');
% display the decrypted message
figure(3)
imshow(plainImage);
title('Decrypted Image');