Saturday 12 May 2018

LSB replacement STEGANOGRAPHY code

msg=[2,0,1,3];
msg_length=length(msg);
msg_product=msg_length*8;
loc_msg=1;
count_msgbit=1;

carrier_image=imread('G:/anshita software/octave/images used/woman.jpg');
im_value=carrier_image;
#im_value=15*ones(35);

if (msg_product<=255)
  for index=1:1:msg_product
 
    # binary conversion of image
    a_image=im_value(1,index,1);
    b_imageVector=dec2bin(a_image);
    c_image=str2double(b_imageVector);
    binary_image=c_image;
    lsb_image=bitget(c_image,1);
 
    # binary conversion of message
    if (count_msgbit>8)
      count_msgbit=1;
      loc_msg++;
    end
    a_msg=msg(1,loc_msg);
    b_msgVector=dec2bin(a_msg);
    c_msg=str2double(b_msgVector);
    msg_bit=bitget(c_msg,count_msgbit);
    c=count_msgbit++;
 
    #assigning msg values to image lsb
    lsb_image=msg_bit;
      if (lsb_image == 0)
        new_binaryimage=bitset(binary_image,1,0)
      else
        new_binaryimage=bitset(binary_image,1,1)
     
      end
   
   
     #assigning values to image matrix_type
     dec_imageValue=bin2dec(num2str(new_binaryimage));
     dummy=dec_imageValue
     index
     im_value(1,index,1)=dummy;
   
   
   
   
 
    end
end

image(im_value)

Steganography is the way to secretly embed message into image.
I have written an OCTAVE code to embed a message to image. This type of steganography is called LSB replacement steganography.
last bit of each pixel is replaced by message bit.
Images are in the form of RGB. But i am taking a 2 d matrix just as an example.


No comments:

Post a Comment

Program to solve 4 variable equation(octave code)

function [x,y,z,alpha]=eq4variable( aaaa1,bbbb1,dddd1,eeee1,cccc1,aaaa2,bbbb2,dddd2,eeee2,cccc2,aaaa3,bbbb3,dddd3,eeee3,cccc3,aaaa4,bbbb4,d...