How to read LSB of audio sample?

7 visualizzazioni (ultimi 30 giorni)
manisha sharma
manisha sharma il 27 Mar 2015
Commentato: manisha sharma il 29 Mar 2015
Hello everyone... I am working on audio steganography project.And i need to read and manipulate LSB of the audio sample.Please tell me a way to do this. Thanks in advance.
  2 Commenti
manisha sharma
manisha sharma il 27 Mar 2015
The audio samples are in floating point representation.When i use dec2bin to convert the floating point number in binary, it only shows binary equivalent of digits before decimal point.But i want to reach LSB of the sample.
James Tursa
James Tursa il 27 Mar 2015
Do you simply want to overwrite the trailing least significant byte of the mantissa with a different bit pattern? I.e., change the floating point value slightly but have your desired pattern embedded in the trailing bits?

Accedi per commentare.

Risposta accettata

James Tursa
James Tursa il 27 Mar 2015
Here is an example of overwriting the least significant byte of a double with other bit patterns, in this case the string 'hidden':
% Arbitraty 6 element double vector
>> x = rand(1,6)
x =
0.957166948242946 0.485375648722841 0.800280468888800 0.141886338627215 0.421761282626275 0.915735525189067
% Find the location of the least significant byte in the double for this machine
>> LSB = find(typecast(1,'uint8')~=typecast(1+eps,'uint8'))
LSB =
1
% Re-interpret the bytes of the double vector as a uint8 vector
>> u = typecast(x,'uint8')
u =
Columns 1 through 35
153 127 112 148 28 161 238 63 82 133 98 6 101 16 223 63 124 40 48 201 229 155 233 63 216 151 19 224 84 41 194 63 202 83 230
Columns 36 through 48
8 35 254 218 63 32 30 143 150 180 77 237 63
% Our replacement data
>> s = 'hidden'
s =
hidden
% Construct the indexes for the replacement bytes
>> lower_bound = LSB
lower_bound =
1
>> upper_bound = LSB + 8*(numel(s)-1)
upper_bound =
41
% Replace the floating data with our new data
>> u(lower_bound:8:upper_bound) = s
u =
Columns 1 through 35
104 127 112 148 28 161 238 63 105 133 98 6 101 16 223 63 100 40 48 201 229 155 233 63 100 151 19 224 84 41 194 63 101 83 230
Columns 36 through 48
8 35 254 218 63 110 30 143 150 180 77 237 63
% Turn result back into double vector (note result is close to original x)
>> y = typecast(u,'double')
y =
0.957166948242940 0.485375648722843 0.800280468888797 0.141886338627212 0.421761282626269 0.915735525189076
% Now do the reverse to recover our hidden data
% Re-interpret the bytes of the double vector as a uint8 vector
>> w = typecast(y,'uint8')
w =
Columns 1 through 35
104 127 112 148 28 161 238 63 105 133 98 6 101 16 223 63 100 40 48 201 229 155 233 63 100 151 19 224 84 41 194 63 101 83 230
Columns 36 through 48
8 35 254 218 63 110 30 143 150 180 77 237 63
% Pick off our hidden bytes and re-interpret as a string
>> char(w(lower_bound:8:upper_bound))
ans =
hidden
  3 Commenti
manisha sharma
manisha sharma il 28 Mar 2015
I have no knowledge about uint8.So can you please tell me about the use of uint8 (in the above example you have given).
Also it seems that for decoding we need to know the length of message 's'.Is it so?
Because while calculating Upper_bound we need length of 's' ie. our text message. But on the decoding time we have our encoded audio only.So i think, i need to embed the value of Upper_bound in audio itself.
This is what i think.Please can you clear my doubts?
Thanks...
manisha sharma
manisha sharma il 29 Mar 2015
This method is not working for audio samples.May be because audio samples have large digits after decimal, example 3.0518e-004
What should i do?

Accedi per commentare.

Più risposte (0)

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by