-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExtractHiddenByte.m
More file actions
25 lines (19 loc) · 789 Bytes
/
ExtractHiddenByte.m
File metadata and controls
25 lines (19 loc) · 789 Bytes
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
function byte = ExtractHiddenByte(array,n)
% Function ExtractHiddenByte extracts a specified byte from a 1D array
% which contians hidden information within the least significant digits
% Input:
% array: A 1D array of values which contains hidden information in the LSBs
% n: The byte position to extract
% Output:
% byte: A 1D array of 8 elements of 1s and 0s representing one byte of
% information hidden
%
% Author: Henry Huang
i = (n-1)*8+1; % Finding the starting index
A = double(array(i:i+7)); %locating the 8 elements and converting to double for calculations
byte = mod(A,2); % Modulo function with respect to 2
byte = uint8(byte); %Convert back into uint8 class
if size(byte,1) > 1 % If its a column vector, transpose into row vector
byte = byte.';
end
end