-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHideText.m
More file actions
36 lines (32 loc) · 1.31 KB
/
HideText.m
File metadata and controls
36 lines (32 loc) · 1.31 KB
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
function stegoArray = HideText(carrierArray,message)
% Function HideText hides a text message in the LSB of elements within a
% 1D array (containing integers)
% Input:
% carrierArray: A 1D array of integer values, can be row or column vector
% and can be an array of uint8 or double values
% message: A character vector containing a message to hide
% Output:
% stegoArray: A 1D array of values modified to contain the hidden
% message, same size and type as input carrierArray
%
% Author: Henry Huang
len = length(message);
stegoArray = carrierArray; %Ensure its same size and type as carrierArray
for i = 1:len
charBits = Char2ByteArray(message(i)); % Find the character bits of letter
for j = 1:8
arrayI = (i-1)*8 + j; % Find array Index for this bit
currentBit = charBits(j);
currentValue = stegoArray(arrayI); % Find current bit and current value
if currentBit == 1 % Check if bit is equal to 1
if mod(currentValue,2) == 0
stegoArray(arrayI) = currentValue + 1; % Add 1 to value if its even, leave same if odd
end
else % Now bit is equal to 0
if mod(currentValue,2) == 1
stegoArray(arrayI) = currentValue - 1; % Subtract 1 if value is odd, leave same if even
end
end
end
end
end