Saturday, December 7, 2013

LSB in steganography

Steganography is very interesting. A simple method is LSB. We hide our information bit by bit in every pixel, and the number of bits and position of hidden bits are determined by our program. I've finished LSB for a long time but don't spread my implementation considering my poor programming ability. But impressed by my "elegant" code, I decided to share it in this blog. (In fact, I was inspired by someone else's code but couldn't think of where and who, please contact me if you have any opinions)

MATLAB makes people process image quite easily, so I used MATLAB to finish it. Here is my code :

% secret : matrix made of hidden infomation
% carrier: matrix made of pixel
% extract: matrix to store hidden information
% N: position, usually equaling 1
carrier = bitor( bitand(carrier, bitcmp(2^N-1, 8)), secret );
extract = uint8( bitand( 255, bitshift(carrier, 8-N)));

P.S. To implement a function, you might need dec2bin() mat2str() bin2dec() for support.

No comments:

Post a Comment