Results 1 to 8 of 8
  1. #1
    raj.mscking@gmail.com's Avatar
    raj.mscking@gmail.com is offline Senior Member
    Join Date
    Jan 2012
    Location
    TamilNadu
    Posts
    288
    Rep Power
    3

    Default Cryptography with StegoGraphy

    Good To Meet You All Genius!

    I Have an Problem in java project,

    Stenography;

    in stenography project, i can hide text in side a wav file and can retrieve by secure pass word..,

    carrier - .wav file
    hidden - text file

    But!

    i wants to combine Cryptography with Stenography the same way..,

    carrier - images (any format)
    Hidden - audio (any format)

    Any one can Guide me please..,
    or is their any website to refer it..,
    Thank you..,

    My mail id - raj.mscking@gmail.com..,


    Java Code:
    // Part of Algorithm code
    
    
    
    public void run()
    {
    try
    {
    recv r=new recv();
    }
    catch(Exception e)
    {
    System.out.println(e);
    }
    }
    
    public void Audioencrypt(String message,File file,int key) throws
    Exception
    {
    byte b[]=new byte[1];
    BigInteger Abi,Mbi;
    int k,k1;
    InputStream ins=new FileInputStream(file);
    OutputStream outs=new FileOutputStream(new File("../ct/src/stenogrpy/Sound Effect - Cat Angry Meow.wav"));
    for(int c=0;c<key;c++)
    {
    int ch=ins.read();
    outs.write(ch);
    }
    int len=message.length();
    byte mess[]=new byte[1];
    char chmess[]=new char[len+1];
    k=k1=0;
    for(int i=0;i<=len;i++)
    {
    message.getChars(0,len,chmess,0);
    if(i==0)
    {
    BigDecimal bd=new BigDecimal(len);
    BigInteger Blen=bd.toBigInteger();
    String Slen=Blen.toString(2);
    char Clen[]=new char[Blen.bitLength()];
    Slen.getChars(0,Blen.bitLength(),Clen,0);
    for(int j=0;j<=7;j++)
    {
    if(j==0)
    {
    for(k=0;k<8-Blen.bitLength();k++)
    {
    int n=ins.read(b);
    Abi=new BigInteger(b);
    String Aby=Abi.toString(2);
    int Alen=Abi.bitLength();
    if(b[0]<0)
    Alen++;
    char Ach[]=new char[Alen+1];
    Aby.getChars(0,Alen,Ach,0);
    
    if(b[0]==0)
    {
    }
    else
    {
    if(Ach[Alen-1]=='1')
    {
    if(Alen==Abi.bitLength())
    {
    BigInteger bi=new BigInteger("11111110",2);
    BigInteger big=Abi.and(bi);
    b=big.toByteArray();
    }
    else
    {
    BigInteger bi=new BigInteger("-1",2);
    BigInteger big=Abi.subtract(bi);
    b=big.toByteArray();
    }
    }
    outs.write(b);
    }
    } //for loop k
    j=j+k-1;
    } // if of j
    else
    {
    int n=ins.read(b);
    Abi=new BigInteger(b);
    String Aby=Abi.toString(2);
    int Alen=Abi.bitLength();
    if(b[0]<0)
    Alen++;
    char Ach[]=new char[Alen+1];
    Aby.getChars(0,Alen,Ach,0);
    if(b[0]==0)
    {
    Alen=1;
    }
    if(Clen[j-k]=='0' && Ach[Alen-1]=='1')
    {
    if(Alen==Abi.bitLength())
    {
    BigInteger bi=new BigInteger("11111110",2);
    BigInteger big=Abi.and(bi);
    b=big.toByteArray();
    }
    else
    {
    BigInteger bi=new BigInteger("-1",2);
    BigInteger big=Abi.subtract(bi);
    b=big.toByteArray();
    }
    }
    else if(Clen[j-k]=='1' && Ach[Alen-1]=='0')
    {
    if(Alen==Abi.bitLength())
    {
    BigInteger bi=new BigInteger("1",2);
    BigInteger big=Abi.add(bi);
    b=big.toByteArray();
    }
    else
    {
    BigInteger bi=new BigInteger("-1",2);
    BigInteger big=Abi.add(bi);
    b=big.toByteArray();
    }
    
    }
    outs.write(b);
    } // end else
    
    } // for loop j
    
    } // end of if
    
    else
    {
    String slen=String.valueOf(chmess[i-1]);
    byte blen[]=slen.getBytes();
    BigInteger Blen=new BigInteger(blen);
    String Slen=Blen.toString(2);
    char Clen[]=new char[Blen.bitLength()];
    Slen.getChars(0,Blen.bitLength(),Clen,0);
    for(int j=0;j<=7;j++)
    {
    if(j==0)
    {
    for(k1=0;k1<8-Blen.bitLength();k1++)
    {
    int n=ins.read(b);
    Abi=new BigInteger(b);
    String Aby=Abi.toString(2);
    int Alen=Abi.bitLength();
    if(b[0]<0)
    Alen++;
    char Ach[]=new char[Alen+1];
    Aby.getChars(0,Alen,Ach,0);
    if(b[0]==0)
    {
    
    }
    else
    {
    if(Ach[Alen-1]=='1')
    {
    if(Alen==Abi.bitLength())
    {
    BigInteger bi=new BigInteger("11111110",2);
    BigInteger big=Abi.and(bi);
    b=big.toByteArray();
    }
    else
    {
    BigInteger bi=new BigInteger("-1",2);
    BigInteger big=Abi.subtract(bi);
    b=big.toByteArray();
    }
    }
    }
    outs.write(b);
    
    } //for loop k
    
    j=j+k1-1;
    
    } // if of j
    
    else
    {
    int n=ins.read(b);
    Abi=new BigInteger(b);
    String Aby=Abi.toString(2);
    int Alen=Abi.bitLength();
    if(b[0]<0)
    Alen++;
    char Ach[]=new char[Alen+1];
    Aby.getChars(0,Alen,Ach,0);
    if(b[0]==0)
    {
    Alen=1;
    }
    
    if(Clen[j-k1]=='0' && Ach[Alen-1]=='1')
    {
    if(Alen==Abi.bitLength())
    {
    BigInteger bi=new BigInteger("11111110",2);
    BigInteger big=Abi.and(bi);
    b=big.toByteArray();
    }
    else
    {
    BigInteger bi=new BigInteger("-1",2);
    BigInteger big=Abi.subtract(bi);
    b=big.toByteArray();
    }
    }
    else if(Clen[j-k1]=='1' && Ach[Alen-1]=='0')
    {
    if(Alen==Abi.bitLength())
    {
    BigInteger bi=new BigInteger("1",2);
    BigInteger big=Abi.add(bi);
    b=big.toByteArray();
    }
    else
    {
    BigInteger bi=new BigInteger("-1",2);
    BigInteger big=Abi.add(bi);
    b=big.toByteArray();
    }
    }
    outs.write(b);
    } // end else
    
    } // for loop j
    } // end of else
    
    } // for loop i
    
    while(true)
    {
    int i=ins.read();
    if(i==-1) break;
    outs.write(i);
    }
    ins.close();
    outs.close();
    }
    
    public void Audiodecrypt(File filename,int key)throws Exception
    {
    InputStream ins=new FileInputStream(filename);
    byte b[]=new byte[1];
    BigInteger bb1;
    char mess[]=new char[8];
    int c=0;
    for(int i=0;i<key;i++)
    {
    int n=ins.read();
    }
    for(int i=0;i<8;i++)
    {
    ins.read(b);
    bb1=new BigInteger(b);
    String str=bb1.toString(2);
    int len=bb1.bitLength();
    if(b[0]<0)
    len++;
    char ch[]=new char[len+1];
    str.getChars(0,len,ch,0);
    if(b[0]==0)
    mess[i]='0';
    else
    mess[i]=ch[len-1];
    }
    String dd=new String(mess);
    BigInteger bb=new BigInteger(dd,2);
    String s=bb.toString(2);
    int l=bb.intValue();
    
    char me[]=new char[l];
    int count=0;
    
    for(int m=0;m<l;m++)
    {
    for(int i=0;i<8;i++)
    {
    ins.read(b);
    bb1=new BigInteger(b);
    String str=bb1.toString(2);
    int len=bb1.bitLength();
    if(b[0]<0)
    len++;
    char ch[]=new char[len+1];
    str.getChars(0,len,ch,0);
    if(b[0]==0)
    mess[i]='0';
    else
    mess[i]=ch[len-1];
    }
    String dd1=new String(mess);
    BigInteger bb2=new BigInteger(dd1,2);
    String s1=bb2.toString(2);
    int l1=bb2.intValue();
    me[count]=(char)l1;
    count++;
    }
    
    String message=new String(me);
    Amessage.setText(message);
    ins.close();
    
    }
    
    public void actionPerformed(ActionEvent ae)
    {
    
    try
    {
    
    // Action for encryption button
    
    if(ae.getSource()==Bencrypt)
    {
    if(Copened==1)
    {
    Ekey=JOptionPane.showInputDialog("Enter The Key For Encryption");
    //String type
    if(Ekey.trim().equals(""))
    JOptionPane.showMessageDialog(this,"EntertheKey","Error",JOptionPane.ERROR_MESSAGE);
    else
    {
    // encrypt the message
    int key=Integer.parseInt(Ekey);
    Audioencrypt(Amessage.getText(),Ofilename,key);
    Cencrypt=1;
    }
    }
    else
    {
    JOptionPane.showMessageDialog(this,"File NotOpened","Error",JOptionPane.ERROR_MESSAGE);
    }
    } // end of Bencrypt
    
    // Action for Clear button
    
    else if(ae.getSource()==Bclear)
    {
    Amessage.setText("");
    } // end of clear button
    
    // Action for Decrypt button
    
    else if(ae.getSource()==Bdecrypt)
    {
    if(Copened==1)
    {
    Dkey=JOptionPane.showInputDialog("Enter The Key For Decryption");
    //String type
    if(Dkey.trim().equals(""))
    JOptionPane.showMessageDialog(this,"Enter theKey","Error",JOptionPane.ERROR_MESSAGE);
    else
    {
    // decrypt message
    int key=Integer.parseInt(Dkey);//raj
    Audiodecrypt(Ofilename,key);
    Cdecrypt=1;
    }
    }
    else
    JOptionPane.showMessageDialog(this,"File NotOpened","Error",JOptionPane.ERROR_MESSAGE);
    } // end of Decrypt button
    
    // Action for Play button
    
    else if(ae.getSource()==Bplay)
    {
    if(Copened==1)
    {
    
    ins=new FileInputStream(Ofilename);
    as=new AudioStream(ins);
    AudioPlayer.player.start(as);
    Cplay=1;
    Cstop=0;
    
    } // start playing
    
    else
    JOptionPane.showMessageDialog(this,"File NotOpened","Error",JOptionPane.ERROR_MESSAGE);
    
    } // end of play button
    
    
    
    // Action for Stop button
    
    else if(ae.getSource()==Bstop)
    {
    
    if(Cplay==1)
    {
    
    Cplay=0;
    Cstop=1;
    AudioPlayer.player.stop(as);
    
    } // stop plaing
    
    else
    
    JOptionPane.showMessageDialog(this,"No Audio Isplaying","Error",JOptionPane.ERROR_MESSAGE);
    
    } // end of stop button
    
    
    
    // Action for open Button
    
    else if(ae.getSource()==Bopen)
    {
    int r=filechooser.showOpenDialog(this);
    tempfilename=filechooser.getSelectedFile(); //File type
    if(r==JFileChooser.CANCEL_OPTION)
    JOptionPane.showMessageDialog(this,"File NotSelected","Error",JOptionPane.ERROR_MESSAGE);
    else
    {
    name=tempfilename.getName();
    
    if(!(name.endsWith(".wav")))
    
    JOptionPane.showMessageDialog(this,"Select OnlyWav","Error",JOptionPane.ERROR_MESSAGE);
    
    else
    {
    Copened=1;
    Ofilename=tempfilename;
    Tfilename.setEditable(true);
    Tfilename.setText(name);
    Tfilename.setEditable(false);
    }
    
    }
    } // end of Open button
    
    // Action for Save Button
    
    else if(ae.getSource()==Bsave)
    {
    if(Copened==1 && Cencrypt==1 || Cdecrypt==1)
    {
    int r=filechooser.showSaveDialog(this);
    Sfilename=filechooser.getSelectedFile(); //File type
    InputStream in=new FileInputStream("../ct/src/stenogrpy/Sound Effect - Cat Angry Meow.wav");
    OutputStream out=new FileOutputStream(Sfilename);
    Ofilename=Sfilename;
    name=Sfilename.getName();
    Tfilename.setEditable(true);
    Tfilename.setText(name);
    Tfilename.setEditable(false);
    while(true)
    {
    int i=in.read();
    if(i==-1) break;
    out.write(i);
    }
    in.close();
    out.close();
    }
    else
    {
    String s;
    if(Copened==0)
    s="File not Opened";
    else if(Cencrypt==0)
    s="Not Encrypted";
    else
    s="Not Decrypted";
    
    JOptionPane.showMessageDialog(this,s,"Error",JOptionPane.ERROR_MESSAGE);
    }
    } // end of save button
    
    // Action for send button
    
    else if(ae.getSource()==Bsend)
    {
    if(Copened==1 && Cencrypt==1)
    {
    address=JOptionPane.showInputDialog("Enter The IPaddress");
    ipaddress=InetAddress.getByName(address);
    Socket socket=new Socket(ipaddress,6000);
    OutputStream out=socket.getOutputStream();
    InputStream in=new FileInputStream(Ofilename);
    while(true)
    {
    int i=in.read();
    if(i==-1) break;
    out.write(i);
    }
    in.close();
    out.close();
    }
    else
    {
    String s;
    if(Copened==1)
    s="Encryption not done";
    else
    s="Open the File first";
    
    JOptionPane.showMessageDialog(this,s,"Error",JOptionPane.ERROR_MESSAGE);
    }
    }
    
    } // end try
    catch(Exception e)
    {
    //
    JOptionPane.showMessageDialog(this,e,"Error",JOptionPane.ERROR_MESSAGE);
    }
    
    } // e

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,423
    Rep Power
    20

    Default Re: Cryptography with StegoGraphy

    tl;dr. But it's Steganography, not
    StegoGraphy
    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    raj.mscking@gmail.com's Avatar
    raj.mscking@gmail.com is offline Senior Member
    Join Date
    Jan 2012
    Location
    TamilNadu
    Posts
    288
    Rep Power
    3

    Default Re: Cryptography with StegoGraphy

    sorry sir!
    that was my spelling mistake..,
    Thank you..,

  4. #4
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,562
    Rep Power
    25

    Default Re: Cryptography with StegoGraphy

    Please use proper indentation in your posted code. Code without indentations is very hard to read.

  5. #5
    raj.mscking@gmail.com's Avatar
    raj.mscking@gmail.com is offline Senior Member
    Join Date
    Jan 2012
    Location
    TamilNadu
    Posts
    288
    Rep Power
    3

    Default Re: Cryptography with StegoGraphy

    Ok sir Thank You!
    hereafter i will fallow as you said..,

  6. #6
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,562
    Rep Power
    25

    Default Re: Cryptography with StegoGraphy

    Waiting for the proper editing of the code.

  7. #7
    raj.mscking@gmail.com's Avatar
    raj.mscking@gmail.com is offline Senior Member
    Join Date
    Jan 2012
    Location
    TamilNadu
    Posts
    288
    Rep Power
    3

    Default Re: Cryptography with StegoGraphy

    Sorry sir! now only i back to lab
    where to place my code (proper editing), please replay me..,

  8. #8
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,562
    Rep Power
    25

    Default Re: Cryptography with StegoGraphy

    where to place my code
    Here on the forum so it can be read.

Similar Threads

  1. Cryptography
    By BizzPu in forum Networking
    Replies: 0
    Last Post: 01-28-2012, 04:50 PM
  2. Cryptography Efficiency
    By joshdgreen in forum Advanced Java
    Replies: 22
    Last Post: 10-29-2010, 09:16 AM
  3. java.util.jar and cryptography
    By telltera in forum New To Java
    Replies: 1
    Last Post: 09-30-2010, 08:54 AM
  4. Cryptography Problem (BadPaddingException)
    By LStrike in forum Advanced Java
    Replies: 5
    Last Post: 03-09-2010, 07:53 PM
  5. cryptography
    By swathi palla in forum AWT / Swing
    Replies: 2
    Last Post: 02-19-2009, 01:51 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •