Você está na página 1de 45

STEGANOGRAPHY SECURITY SYSTEM

Submitted in partial fulfilment of the requirements For the award of the degree of

Bachelor of Technology

In
Information Technology

ProjectGuide: Ms. Mansi Jhamb Assistant Professor USIT, GGSIPU

Submitted By: Ashish Sharma 0801641508

University School of Information Technology GGS Indraprastha University, Dwarka, Delhi-75


(2008-2012)

Table of Contents
CERTIFICATE ..................................................................................................................................... 3 DECLARATION .................................................................................................................................. 4 ACKNOWLEDGEMENT ...................................................................................................................... 5 1.INTRODUCTION: ............................................................................................................................ 6 2.SOFTWARE REQUIREMENTS SPECIFICATION ................................................................................. 7 3. JAVA ........................................................................................................................................... 10 4. JAVA SWINGS ............................................................................................................................. 11 5. STEGANOGRAPHY ...................................................................................................................... 13 6. DATA ENCRYPTION STANDARD ALGORITHM .............................................................................. 14 7. SECURITY IN JAVA ...................................................................................................................... 16 8. SNAPSHOTS ................................................................................................................................ 17 9. CODE .......................................................................................................................................... 21 10. CONCLUSION: ........................................................................................................................... 44 11. FUTURE ENHANCEMENTS: ........................................................................................................ 44 12. REFERENCES ............................................................................................................................. 45

CERTIFICATE

This is to certify that the project report (IT 452) entitled Steganography Security System done by ASHISH SHARMA, Roll No. 0801641508 is carried out by him at USIT, GGSIPU under my guidance.

Date:

Ms. MANSI JHAMB


(Assistant Professor USIT, GGSIPU)

DECLARATION

I, Ashish Sharma, hereby declare that the project work, which is being presented here, entitled Steganography Security System, is an authentic work carried out by me at University School of Information Technology, Delhi, under the guidance of Ms. Mansi Jhamb of USIT, GGSIPU and this has not been submitted anywhere else for the award of any other degree/diploma.

Date:

ASHISH SHARMA (0801641508)

ACKNOWLEDGEMENT

I would like to express our deep thanks towards our respected guide Ms.Mansi Jhamb of USIT for the confidence shown in me in giving me an opportunity to work on a new idea and learn and explore under her able guidance. The pragmatic and invaluable advice of our guide kept us going through the critical phases of my project. I am indebted to her for her insightful and encouraging words that have been driving force of our project. She provided me with lot of information and ideas regarding the project. Her sincere guidance and industrious attitude seeped in me, inspiring me to reach beyond limits.

(Ashish Sharma)

1.Introduction:
Developed software can be deployed for any organization, Home applications or for secure confidential chatting system. The requirements can be modified as per need i.e. user may want to chat or transfer a file over the system. Here we a developing the software as an application which can be used at the server or receiver end for encoding and retrieving the data. Here user is provided a number of options that can be used. Basic Needs of the Project are : 1. Users: Persons who will use this application. 1.1 User1: who will encode and hide the data before transmission 1.2 User2: who will decode the data and retrieve that from image. 2. Software: 2.1 Jdk tool kit: Java tools for the development of the project code. 2.2 Java Swings: for generating a graphical user interface and make more user friendly project. 2.3 Awt: Abstract window toolkit 3. Language: 3.1Java: to generate the code and make an application code that can run on its self like other softwares. 4. Operating System: Windows xp and windows vista

2.Software Requirements Specification


1. Introduction: Our software will allow the user to transmit the data after hiding that into an image. The data to be transmitted will not just be hidden in image but also it will be encrypted by the password. This password will also act as key for encryption. All sort of security and various levels of compression can also be done with the user Requirements. 1.1 Purpose: To make the entire System over the network secure. Security is provided with encryption and through obscurity. Encryption algorithm used is DES(Data Encryption Standards). For obscurity Steganography is used. 1.2 Scope: this project has no limitation of windows or software as the complied for of the code provided can be used on any system. The system will just be loaded with the java tools. Interface designed will make the user more friendly with the system. 1.3 References: In order to use various software required to make this project Internet or particular books on Java Swings and Steganography must be used. The programmer must have a knowledge of Java Source coding, java Swings and Security features available in java. Various books related to these topics have been used to make the project 1.4 Overview: The SRS contains the details of types of users, data that is to be encrypted, file that need to be encrypted and revealing all the data. Compression of data is also done that is to be understood by you. 2. Overall Description: Project is not affected by the memory requirement because very Simple software used to make this project like Java. Java uses the command line to execute the code. 2.1 Product Perspective: It isa complete real time software. It can be used as a part of large system or it can also be used with in home or LAN network. 2.1.1 System Interface: Users will interact with the help of the Graphical user interface provided by the software. As Java is platform independent and based on just a Basic command line it can be loaded on any Operating System. Hence, no specific software requirement to use it.

2.1.2 Interfaces: Each page opened must have a link to cancel and change the selected option. No specific logins are provided so can be used anywhere.

2.1.3 Hardware Interfaces: there are no specific hardware requirements for the project. 2.1.4 Software Interfaces: In order to make this project various software are required.Jdk: create and execute java applications. 2.1.5 Communication Interface: No specific communication interface required for this project to execute because of platform independence of Java. 2.1.6 Memory Constraints: RAM memory should be large enough to execute the java code. 2.1.7 Operations: The project will work in four types of conditions: 2.1.7.1 2.1.7.2 2.1.7.3 2.1.7.4 Embed message. Embed file Retrieve message Retrieve file

Apart from this Encryption will be allowed. Compression can be done at a scale of 0-9 so that high and low compression cold be permitted. 2.2 Product Functions: the software will perform following function: 2.2.1 Encryption of message 2.2.2 Encryption of file 2.2.3 Compression of message 2.2.4 Compression of file 2.2.5 Encryption and compression of message/ File 2.2.6 Embedding all above into an image. 2.3 User Characteristics: Any one can access the Software as no user authentication is being done. It is assumed that person who is using the system is authorized to use the software. 2.4 Assumptions and Dependencies: we have assumed that a person know how use a computer system. User may want to end at any time. Person sing
8

software is already authorized if used in organisation. As key is same for encryption and decryption so key is exchanged through some secured channel 3. Specific Requirements: 3.1 External Interface: There are no specific external interface requirements to build/use this project just the basic needs of softwares and hardware are required. 3.2 Functions: Apart from the functions provided to users the developer must take care of the inputs provided by the user like appropriate length of the password. 3.3 Performance requirement: for the better performance of the system no specific requirements are there.

3.4 Software System Attributes: These are characteristics the system must possess, but that pervade the design. These requirements have to be testable just like the functional requirements.

3.4.1 Reliability: The inconsistency must be removed completely so that the outputs must be completely reliable. Also functioning should be detailed with the current details of the databases so that Output too are consistent.

3.4.2Availability: Software should be available to everyone using it because it is based on their structure. No Specific modifications are required in the software.

3.4.3Maintainability: Software maintenance will require testing of system after some intervals. These systems must be tested.

3.4.4Portability: Software must be portable to all the systems because of the language used. Secondly no specific h/w or s/w requirement will make it more easily usable.

3. JAVA
Introduction:

Java is a powerful, cross-platform, object-oriented programming language suitable for writing anything from a distributed application that runs on a corporate network to a database-driven Web site to host your personal photo gallery. To make it easier to learn, the Java language was designed to resemble some of the most popular programming languages in use today, most notably C/C++.

Advantages and Disadvantages of using JAVA:

Java has the following advantages for the development of software in an academic environment:

Tailored for the Internet. Platform Independent Interactive Content Computation Aspects Java Applications Run Locally Security

Some disadvantages of using Java include the following:


Programming Knowledge Performance Concerns Available Code

10

4. Java Swings
The Swing toolkit includes a rich set of components for building GUIs and adding interactivity to Java applications. Swing includes all the components you would expect from a modern toolkit: table controls, list controls, tree controls, buttons, and labels. Swing is part of the Java Foundation Classes (JFC). The JFC also include other features important to a GUI program, such as the ability to add rich graphics functionality and the ability to create a program that can work in different languages and by users with different input devices. The following list shows some of the features that Swing and the Java Foundation Classes provide. Swing GUI Components The Swing toolkit includes a rich array of components: from basic components, such as buttons and check boxes, to rich and complex components, such as tables and text. Even deceptively simple components, such as text fields, offer sophisticated functionality, such as formatted text input or password field behavior. There are file browsers and dialogs to suit most needs, and if not, customization is possible. Java 2D API To make your application stand out; convey information visually; or add figures, images, or animation to your GUI, you'll want to use the Java 2DTM API. Because Swing is built on the 2D package, it's trivial to make use of 2D within Swing components. Adding images, drop shadows, compositing it's easy with Java 2D. Pluggable Look-and-Feel Support Any program that uses Swing components has a choice of look and feel. The JFC classes shipped by Sun and Apple provide a look and feel that matches that of the platform. The Synth package allows you to create your own look and feel. The GTK+ look and feel makes hundreds of existing look and feels available to Swing programs. A program can specify the look and feel of the platform it is running on, or it can specify to always use the Java look and feel, and without recompiling, it will just work. Or, you can ignore the issue and let the UI manager sort it out. Data Transfer Data transfer, via cut, copy, paste, and drag and drop, is essential to almost any application. Support for data transfer is built into Swing and works between Swing components within an application, between Java applications, and between Java and native applications.

11

Accessibility API People with disabilities use special software assistive technologies that mediates the user experience for them. Such software needs to obtain a wealth of information about the running application in order to represent it in alternate media: for a screen reader to read the screen with synthetic speech or render it via a Braille display, for a screen magnifier to track the caret and keyboard focus, for on-screen keyboards to present dynamic keyboards of the menu choices and toolbar items and dialog controls, and for voice control systems to know what the user can control with his or her voice. The accessibility API enables these assistive technologies to get the information they need, and to programmatically manipulate the elements that make up the graphical user interface. Undo Framework API Swing's undo framework allows developers to provide support for undo and redo. Undo support is built in to Swing's text component. For other components, Swing supports an unlimited number of actions to undo and redo, and is easily adapted to an application. For example, you could easily enable undo to add and remove elements from a table. It allows the user to create user view to display various items in proper manner and make it user friendly. Some of these are: Button Checkbox Combo Box Menu List Radio button Slider Spinner Text field Password Field Color Chooser Text pane File Chooser Table Text area Tree Label Tool tip Dialog Frame Scroll pane

12

5. Steganography
Steganography is a familiar idea to readers of detective and spy novels. It involves the hiding of a secret message inside an innocent-looking package or container (often called a carrier). For example, a micro-dot hidden beneath a postage stamp, or a message written in milk on the back of a letter, or instructions tattooed under a person's hair. The cracking of steganographic messages is called steganalysis, and comes in two main forms. The easiest type of cracking simply makes the hidden message unreadable by modifying the carrier. This can usually be achieved by cropping or blurring the image, or saving it in a different file format. A much harder task is the extraction of the hidden message, which typically starts with the identification of tell tale regularities or patterns in the carrier, or spotting differences between the carrier and its original. The simplest form of digital steganography (and probably the most common) is the Least Significant Bit (LSB) method, where the binary representation of the data that's to be hidden is written into the LSB of the bytes of the carrier. The overall change to the image is so minor that it can't be seen by the human eye.

13

6. Data encryption Standard Algorithm


Encryption is a way of scrambling and modifying our message so as to make it intelligible. Encryption can be simple or complex like Caesar cipher in which detection of message is easy to very complex like AES where the key used for encryption is so long that the cost of determining the data is very much. DES: In 1972, National Institute of Standards and Technology decided that a strong encryption algorithm is required to protect non-classified information. That algorithm should be cheap, widely available and very secure. In 1974, IBM submitted Lucifer algorithm which meet most of the requirements. After that it was again modified and termed as DES. DES encrypts and decrypts the data in64 bit blocks, using a 64-bit key. It takes 64 bit block of plain text as input and outputs 64 bit cipher text. Since it uses blocks of equal sizes and it uses both permutation and substitution in the algorithm, DES is both block cipher and product cipher. DES has 16 rounds, meaning the main algorithm is repeated 16 times to produce the cipher text. It has been found that no. of rounds is exponentially proportional to the amount of time required to find a key using a brute force attack. So as the no. of rounds increases the security of algorithm increases. Although the key input is 64 bit but only 56 bits are used. The least significant bit in each byte is parity bit and should be set so that there will always be odd no. of 1s. these parity bits are ignored, so only the seven most significant bits f each byte is used, resulting in key length of 56 bits. Steps to generate key for each round are: 1. Permutation of the input block. 2. Split it into 2 28 bits left and right. 3. Rotate left and right by the same no. of bits as specified. 4. Join left and right to get a new key. 5. Apply second permute to get final key. 6. Repeat the process to get 16 subkeys. Various Steps in Encryption are: 1. Initial permutation is performed on the plain text. 2. Then using S-box substitution 32 bit data is extended to make it 48 bit. 3. 48 bit data is XORed with key and stored in a temporary buffer. 4. Again anSbox substitution is performed on the data. 5. Permutation is performed on the data not obtained in the temporary buffer. 6. It is XORed with the left side 32 bits. Actually DES is a fiestel Structure where the data is divided into left and right parts.
14

The left part remains as such and right hand side is modified and XORed with the left. After every Round the left and right hand side blocks are swapped. Xor operation, S boxes and Permutations are reversible hence original data can be recovered using the same key. Key used is same for encryption and decryption. The security of this technique is based on the complexity to recover original data if key is not known. Time it takes for brute force attack is very large.

15

7. Security in JAVA
The security features provided by the Java Development Kit (JDK) are intended for a variety of audiences:

Users running programs: Built-in security functionality protects you from malevolent programs (including viruses), maintains the privacy of your files and information about you, and authenticates the identity of each code provider. You can subject applications and applets to security controls when you need to.

Developers: You can use API methods to incorporate security functionality into your programs, including cryptography services and security checks. The API framework enables you to define and integrate your own permissions (controlling access to specific resources), cryptography service implementations, security manager implementations, and policy implementations. In addition, classes are provided for management of your public/private key pairs and public key certificates from people you trust.

Systems administrators, developers, and users: JDK tools manage your keystore (database of keys and certificates); generate digital signatures for JAR files, and verify the authenticity of such signatures and the integrity of the signed contents; and create and modify the policy files that define your installation's security policy.

Security functions help you to protect your programs and data from harm, to keep data shielded and private, and to deploy new applications in security-aware runtime environments.
Java also provides several tools to help you to manage access to system resources; to create, store and maintain encrypted public and private passwords (key pairs) and certificates; and to create and sign jar files during the deployment process

16

8. Snapshots
Basic graphic user interface

File chooser

17

Output image and password GUI

Successful encoding message

18

New encoded image

Choosing decode from file menu

19

Asking password for decoding

If password correct then image decoded successfully

The desired text retrieved

20

9. Code
Image_ filter.java file
import java.io.*; /* *Image_Filter Class */ public class Image_Filter extends javax.swing.filechooser.FileFilter { /* *Determines if the extension is of the defined types *@param ext Extension of a file *@return Returns true if the extension is 'jpg' or 'png' */ protected boolean isImageFile(String ext) { return (ext.equals("jpg")||ext.equals("png")); } /* *Determines if the file is a directory or accepted extension *@param f The File to run the directory/proper extension check on *@return Returns true if the File is a directory or accepted extension */ public boolean accept(File f) { if (f.isDirectory()) { return true; } String extension = getExtension(f); if (extension.equals("jpg")||extension.equals("png")) { return true; } return false; } /* *Supplies File type description *@return Returns the String description */ public String getDescription() { return "Supported Image Files"; } /* *Determines the Extension *@param f File to return the extension of *@return Returns the String representing the extension */ protected static String getExtension(File f) {

21

String s = f.getName(); int i = s.lastIndexOf('.'); if (i > 0 && i < s.length() - 1) return s.substring(i+1).toLowerCase(); return ""; } }

Steganography_view.java file
import java.awt.Color; import java.awt.Insets; import java.awt.GridBagLayout; import java.awt.GridBagConstraints; import javax.swing.JMenu; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JLabel; import javax.swing.JButton; import javax.swing.JMenuBar; import javax.swing.JMenuItem; import javax.swing.JTextArea; import javax.swing.JScrollBar; import javax.swing.JScrollPane; import javax.swing.BorderFactory; /* *Class Steganography_View */ public class Steganography_View extends JFrame { //sie variables for window private static int WIDTH = 500; private static int HEIGHT = 400; //elements for JPanel private JTextArea private JScrollBar private JButton private JLabel //elements for Menu private JMenu private JMenuItem private JMenuItem private JMenuItem

input; scroll,scroll2; encodeButton,decodeButton; image_input;

file; encode; decode; exit;

/* *Constructor for Steganography_View class *@param name Used to set the title on the JFrame */ public Steganography_View(String name) { //set the title of the JFrame super(name);

22

//Menubar JMenuBar menu = new JMenuBar(); JMenu file = new JMenu("File"); file.setMnemonic('F'); encode = new JMenuItem("Encode"); encode.setMnemonic('E'); file.add(encode); decode = new JMenuItem("Decode"); decode.setMnemonic('D'); file.add(decode); file.addSeparator(); exit = new JMenuItem("Exit"); exit.setMnemonic('x'); file.add(exit); menu.add(file); setJMenuBar(menu); // display rules setResizable(true); //allow window to be resized: true?false setBackground(Color.lightGray); //background color of window: Color(int,int,int) or Color.name setLocation(200,100); //location on the screen to display window setDefaultCloseOperation(EXIT_ON_CLOSE);//what to do on close operation: exit, do_nothing, etc setSize(WIDTH,HEIGHT); //set the size of the window setVisible(true); //show the window: true?false } /* *@return The menu item 'Encode' */ public JMenuItem getEncode() { return encode; /* *@return The menu item 'Decode' */ public JMenuItem getDecode() { return decode; /* *@return The menu item 'Exit' */ public JMenuItem getExit() { return exit; /* *@return The TextArea containing the text to encode */ public JTextArea getText() { return input; /* *@return The JLabel containing the image to decode text from */ public JLabel getImageInput() { return image_input; /* *@return The JPanel displaying the Encode View */ public JPanel getTextPanel() { return new Text_Panel();} /* *@return The JPanel displaying the Decode View */ public JPanel getImagePanel() { return new Image_Panel(); /* *@return The Encode button */

23

public JButton getEButton() /* *@return The Decode button */ public JButton getDButton()

{ return encodeButton;

{ return decodeButton;

/* *Class Text_Panel */ private class Text_Panel extends JPanel { /* *Constructor to enter text to be encoded */ public Text_Panel() { //setup GridBagLayout GridBagLayout layout = new GridBagLayout(); GridBagConstraints layoutConstraints = new GridBagConstraints(); setLayout(layout); input = new JTextArea(); layoutConstraints.gridx = 0; layoutConstraints.gridy = 0; layoutConstraints.gridwidth = 1; layoutConstraints.gridheight = 1; layoutConstraints.fill = GridBagConstraints.BOTH; layoutConstraints.insets = new Insets(0,0,0,0); layoutConstraints.anchor = GridBagConstraints.CENTER; layoutConstraints.weightx = 1.0; layoutConstraints.weighty = 50.0; JScrollPane scroll = new JScrollPane(input,JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); layout.setConstraints(scroll,layoutConstraints); scroll.setBorder(BorderFactory.createLineBorder(Color.BLACK,1)); add(scroll); encodeButton = new JButton("Encode Now"); layoutConstraints.gridx = 0; layoutConstraints.gridy = 1; layoutConstraints.gridwidth = 1; layoutConstraints.gridheight = 1; layoutConstraints.fill = GridBagConstraints.BOTH; layoutConstraints.insets = new Insets(0,-5,-5,-5); layoutConstraints.anchor = GridBagConstraints.CENTER; layoutConstraints.weightx = 1.0; layoutConstraints.weighty = 1.0; layout.setConstraints(encodeButton,layoutConstraints); add(encodeButton); //set basic display setBackground(Color.lightGray); setBorder(BorderFactory.createLineBorder(Color.BLACK,1)); } } /* *Class Image_Panel */ private class Image_Panel extends JPanel {

24

/* *Constructor for displaying an image to be decoded */ public Image_Panel() { //setup GridBagLayout GridBagLayout layout = new GridBagLayout(); GridBagConstraints layoutConstraints = new GridBagConstraints(); setLayout(layout); image_input = new JLabel(); layoutConstraints.gridx = 0; layoutConstraints.gridy = 0; layoutConstraints.gridwidth = 1; layoutConstraints.gridheight = 1; layoutConstraints.fill = GridBagConstraints.BOTH; layoutConstraints.insets = new Insets(0,0,0,0); layoutConstraints.anchor = GridBagConstraints.CENTER; layoutConstraints.weightx = 1.0; layoutConstraints.weighty = 50.0; JScrollPane scroll2 = new JScrollPane(image_input,JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); layout.setConstraints(scroll2,layoutConstraints); scroll2.setBorder(BorderFactory.createLineBorder(Color.BLACK,1)); image_input.setHorizontalAlignment(JLabel.CENTER); add(scroll2); decodeButton = new JButton("Decode Now"); layoutConstraints.gridx = 0; layoutConstraints.gridy = 1; layoutConstraints.gridwidth = 1; layoutConstraints.gridheight = 1; layoutConstraints.fill = GridBagConstraints.BOTH; layoutConstraints.insets = new Insets(0,-5,-5,-5); layoutConstraints.anchor = GridBagConstraints.CENTER; layoutConstraints.weightx = 1.0; layoutConstraints.weighty = 1.0; layout.setConstraints(decodeButton,layoutConstraints); add(decodeButton); //set basic display setBackground(Color.lightGray); setBorder(BorderFactory.createLineBorder(Color.BLACK,1)); } } /* *Main Method for testing */ public static void main(String args[]) { new Steganography_View("Steganography"); }

25

Steganography_controller.java file
import java.io.File; import java.awt.Container; import java.awt.event.ActionEvent; import java.awt.image.BufferedImage; import java.awt.event.ActionListener; import javax.swing.JPanel; import javax.swing.JLabel; import javax.swing.JButton; import javax.swing.ImageIcon; import javax.swing.JMenuItem; import javax.swing.JPasswordField; import javax.swing.JTextArea; import javax.swing.JTextField; import javax.imageio.ImageIO; import javax.swing.JOptionPane; import javax.swing.JFileChooser; /* *Steganography_Controller Class */ public class Steganography_Controller { //Program Variables private Steganography_View private Steganography //Panel Displays private JPanel private JPanel //Panel Variables private JTextArea private JButton private JLabel //Menu Variables private JMenuItem private JMenuItem private JMenuItem //action event classes private Encode private Decode private EncodeButton private DecodeButton

view; model;

decode_panel; encode_panel; input; encodeButton,decodeButton; image_input; encode; decode; exit;

enc; dec; encButton; decButton;

//decode variable private String stat_path = ""; private String stat_name = ""; private String pass22=""; /* *Constructor to initialize view, model and environment variables *@param aView A GUI class, to be saved as view *@param aModel A model class, to be saved as model

26

*/ public Steganography_Controller(Steganography_View aView, Steganography aModel) { //program variables view = aView; model = aModel; //assign View Variables //2 views encode_panel = view.getTextPanel(); decode_panel = view.getImagePanel(); //2 data options input = view.getText(); image_input = view.getImageInput(); //2 buttons encodeButton = view.getEButton(); decodeButton = view.getDButton(); //menu encode = view.getEncode(); decode = view.getDecode(); exit = view.getExit(); //assign action events enc = new Encode(); encode.addActionListener(enc); dec = new Decode(); decode.addActionListener(dec); exit.addActionListener(new Exit()); encButton = new EncodeButton(); encodeButton.addActionListener(encButton); decButton = new DecodeButton(); decodeButton.addActionListener(decButton); //encode view as default encode_view(); } /* *Updates the single panel to display the Encode View. */ private void encode_view() { update(); view.setContentPane(encode_panel); view.setVisible(true); } /* *Updates the single panel to display the Decode View. */ private void decode_view() { update(); view.setContentPane(decode_panel); view.setVisible(true); }

27

/* *Encode Class - handles the Encode menu item */ private class Encode implements ActionListener { /* *handles the click event *@param e The ActionEvent Object */ public void actionPerformed(ActionEvent e) { encode_view(); //show the encode view } } /* *Decode Class - handles the Decode menu item */ private class Decode implements ActionListener { /* *handles the click event *@param e The ActionEvent Object */ public void actionPerformed(ActionEvent e) { decode_view(); //show the decode view //start path of displayed File Chooser JFileChooser chooser = new JFileChooser("./"); chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); chooser.setFileFilter(new Image_Filter()); int returnVal = chooser.showOpenDialog(view); if (returnVal == JFileChooser.APPROVE_OPTION){ File directory = chooser.getSelectedFile(); try{ String image = directory.getPath(); stat_name = directory.getName(); stat_path = directory.getPath(); stat_path = stat_path.substring(0,stat_path.length()stat_name.length()-1); stat_name = stat_name.substring(0, stat_name.length()-4); image_input.setIcon(new ImageIcon(ImageIO.read(new File(image))));

} catch(Exception except) { //msg if opening fails JOptionPane.showMessageDialog(view, "The File cannot be opened!", "Error!", JOptionPane.INFORMATION_MESSAGE); } } } }

28

/* *Exit Class - handles the Exit menu item */ private class Exit implements ActionListener { /* *handles the click event *@param e The ActionEvent Object */ public void actionPerformed(ActionEvent e) { System.exit(0); //exit the program } } /* *Encode Button Class - handles the Encode Button item */ private class EncodeButton implements ActionListener { /* *handles the click event *@param e The ActionEvent Object */ public void actionPerformed(ActionEvent e) {String pass=null; String stegan=null; JLabel jUserName = new JLabel("File name"); JTextField fileName = new JTextField(); JLabel jPassword = new JLabel("Password"); JTextField password = new JPasswordField(); Object[] ob = {jUserName, fileName, jPassword, password}; //start path of displayed File Chooser JFileChooser chooser = new JFileChooser("./"); chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); chooser.setFileFilter(new Image_Filter()); int returnVal = chooser.showOpenDialog(view); if (returnVal == JFileChooser.APPROVE_OPTION){ File directory = chooser.getSelectedFile(); try{ String text = input.getText(); String ext = Image_Filter.getExtension(directory); String name = directory.getName(); String path = directory.getPath(); path = path.substring(0,path.length()-name.length()-1); name = name.substring(0, name.length()-4); int result = JOptionPane.showConfirmDialog(null, ob, "Please input filename and password", JOptionPane.OK_CANCEL_OPTION); if (result == JOptionPane.OK_OPTION) { stegan = fileName.getText(); pass = password.getText(); //Here is some validation code }

29

else if(result==JOptionPane.CANCEL_OPTION) {System.exit(0); } String k = "5qw8sd4h"; byte[] enc = DES.encrypt(pass.getBytes(), k.getBytes()); if(model.encode(path,name,ext,stegan,text,new String(enc))) { JOptionPane.showMessageDialog(view, "The Image was encoded Successfully!", "Success!", JOptionPane.INFORMATION_MESSAGE); } else { JOptionPane.showMessageDialog(view, "The Image could not be encoded!", "Error!", JOptionPane.INFORMATION_MESSAGE); } //display the new image decode_view(); image_input.setIcon(new ImageIcon(ImageIO.read(new File(path + "/" + stegan + ".png")))); } catch(Exception except) { //msg if opening fails JOptionPane.showMessageDialog(view, "The File cannot be opened!", "Error!", JOptionPane.INFORMATION_MESSAGE); } } } } /* *Decode Button Class - handles the Decode Button item */ private class DecodeButton implements ActionListener { /* *handles the click event *@param e The ActionEvent Object */ public void actionPerformed(ActionEvent e) {JLabel jPassword = new JLabel("Password"); JTextField password = new JPasswordField(); Object[] ob = { jPassword, password}; int result = JOptionPane.showConfirmDialog(null, ob, "Please input password ", JOptionPane.OK_CANCEL_OPTION); if (result == JOptionPane.OK_OPTION) { pass22 = password.getText(); //Here is some validation code

30

} else if(result==JOptionPane.CANCEL_OPTION) {System.exit(0); }

/* pass22= JOptionPane.showInputDialog(view, "Enter password of file :", "password", JOptionPane.PLAIN_MESSAGE);*/ String message = model.decode(stat_path, stat_name,pass22); System.out.println(stat_path + ", " + stat_name); while(message=="") { result = JOptionPane.showConfirmDialog(null, ob, "Please input password for JOptionPane showConfirmDialog", JOptionPane.OK_CANCEL_OPTION); if (result == JOptionPane.OK_OPTION) { pass22 = password.getText(); //Here is some validation code } else if(result==JOptionPane.CANCEL_OPTION) {System.exit(0); } message = model.decode(stat_path, stat_name,pass22); System.out.println(stat_path + ", " + stat_name); } if(message !="") { encode_view(); JOptionPane.showMessageDialog(view, "The Image was decoded Successfully!", "Success!", JOptionPane.INFORMATION_MESSAGE); input.setText(message); } } } /* *Updates the variables to an initial state */ public void update() { input.setText(""); //clear textarea image_input.setIcon(null); //clear image stat_path = ""; //clear path stat_name = ""; //clear name } /* *Main Method for testing */

31

public static void main(String args[]) { new Steganography_Controller( new Steganography_View("Steganography"), new Steganography() ); } }

Stegangraphy.java file
import java.io.File;

import java.awt.Point; import java.awt.Graphics2D; import java.awt.image.BufferedImage; import java.awt.image.WritableRaster; import java.awt.image.DataBufferByte; import javax.imageio.ImageIO; import javax.swing.JOptionPane; /* *Class Steganography */ public class Steganography { /* *Steganography Empty Constructor */ public Steganography() { } /* *Encrypt an image with text, the output file will be of type .png *@param path The path (folder) containing the image to modify *@param original The name of the image to modify *@param ext1 The extension type of the image to modify (jpg, png) *@param stegan The output name of the file *@param message The text to hide in the image *@param type integer representing either basic or advanced encoding */ public boolean encode(String path, String original, String ext1, String stegan, String message,String pass1) { String BufferedImage file_name = image_path(path,original,ext1); image_orig = getImage(file_name);

//user space is not necessary for Encrypting BufferedImage image = user_space(image_orig); image = add_text(image,message,pass1);

32

return(setImage(image,new File(image_path(path,stegan,"png")),"png")); } /* *Decrypt assumes the image being used is of type .png, extracts the hidden text from an image *@param path The path (folder) containing the image to extract the message from *@param name The name of the image to extract the message from *@param type integer representing either basic or advanced encoding */ public String decode(String path, String name,String pass1) { byte[] decode; try { //user space is necessary for decrypting BufferedImage image = user_space(getImage(image_path(path,name,"png"))); decode = decode_text(get_byte_data(image),pass1); return(new String(decode)); } catch(Exception e) { JOptionPane.showMessageDialog(null, "please enter password again!","Error", JOptionPane.ERROR_MESSAGE); return ""; } } /* *Returns the complete path of a file, in the form: path\name.ext *@param path The path (folder) of the file *@param name The name of the file *@param ext The extension of the file *@return A String representing the complete path of a file */ private String image_path(String path, String name, String ext) { return path + "/" + name + "." + ext; } /* *Get method to return an image file *@param f The complete path name of the image. *@return A BufferedImage of the supplied file path *@see Steganography.image_path */ private BufferedImage getImage(String f) { BufferedImage image = null; File file = new File(f); try { image = ImageIO.read(file); }

33

catch(Exception ex) { JOptionPane.showMessageDialog(null, "Image could not be read!","Error",JOptionPane.ERROR_MESSAGE); } return image; } /* *Set method to save an image file *@param image The image file to save *@param file File to save the image to *@param ext The extension and thus format of the file to be saved *@return Returns true if the save is succesful */ private boolean setImage(BufferedImage image, File file, String ext) { try { file.delete(); //delete resources used by the File ImageIO.write(image,ext,file); return true; } catch(Exception e) { JOptionPane.showMessageDialog(null, "File could not be saved!","Error",JOptionPane.ERROR_MESSAGE); return false; } } /* *Handles the addition of text into an image *@param image The image to add hidden text to *@param text The text to hide in the image *@return Returns the image with the text embedded in it */ private BufferedImage add_text(BufferedImage image, String text,String pass2) {String total=pass2+text; //convert all items to byte arrays: image, message, message length byte img[] = get_byte_data(image); byte msg[] =total.getBytes(); byte pass3[]=pass2.getBytes(); byte len[] = bit_conversion(msg.length); byte plen[]=bit_conversion(pass3.length); try { encode_text(img, len, 0); //0 first positiong encode_text(img, plen, 32); encode_text(img,msg , 64);//4 bytes of space for length: 4bytes*8bit = 32 bits } catch(Exception e) { JOptionPane.showMessageDialog(null, "Target File cannot hold message!", "Error",JOptionPane.ERROR_MESSAGE);

34

} return image; } /* *Creates a user space version of a Buffered Image, for editing and saving bytes *@param image The image to put into user space, removes compression interferences *@return The user space version of the supplied image */ private BufferedImage user_space(BufferedImage image) { //create new_img with the attributes of image BufferedImage new_img = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_3BYTE_BGR); Graphics2D graphics = new_img.createGraphics(); graphics.drawRenderedImage(image, null); graphics.dispose(); //release all allocated memory for this image return new_img; } /* *Gets the byte array of an image *@param image The image to get byte data from *@return Returns the byte array of the image supplied *@see Raster *@see WritableRaster *@see DataBufferByte */ private byte[] get_byte_data(BufferedImage image) { WritableRaster raster = image.getRaster(); DataBufferByte buffer = (DataBufferByte)raster.getDataBuffer(); return buffer.getData(); } /* *Gernerates proper byte format of an integer *@param i The integer to convert *@return Returns a byte[4] array converting the supplied integer into bytes */ private byte[] bit_conversion(int i) { //originally integers (ints) cast into bytes //byte byte7 = (byte)((i & 0xFF00000000000000L) >>> 56); //byte byte6 = (byte)((i & 0x00FF000000000000L) >>> 48); //byte byte5 = (byte)((i & 0x0000FF0000000000L) >>> 40); //byte byte4 = (byte)((i & 0x000000FF00000000L) >>> 32); //only using 4 bytes byte byte3 = (byte)((i & 0xFF000000) >>> 24); //0 byte byte2 = (byte)((i & 0x00FF0000) >>> 16); //0 byte byte1 = (byte)((i & 0x0000FF00) >>> 8 ); //0 byte byte0 = (byte)((i & 0x000000FF) ); //{0,0,0,byte0} is equivalent, since all shifts >=8 will be 0 return(new byte[]{byte3,byte2,byte1,byte0}); }

35

/* *Encode an array of bytes into another array of bytes at a supplied offset *@param image Array of data representing an image *@param addition Array of data to add to the supplied image data array *@param offset The offset into the image array to add the addition data *@return Returns data Array of merged image and addition data */ private byte[] encode_text(byte[] image, byte[] addition, int offset) { //check that the data + offset will fit in the image if(addition.length + offset > image.length) { throw new IllegalArgumentException("File not long enough!"); } //loop through each addition byte for(int i=0; i<addition.length; ++i) { //loop through the 8 bits of each byte int add = addition[i]; for(int bit=7; bit>=0; --bit, ++offset) //ensure the new offset value carries on through both loops { //assign an integer to b, shifted by bit spaces AND 1 //a single bit of the current byte int b = (add >>> bit) & 1; //assign the bit by taking: [(previous byte value) AND 0xfe] OR bit to add //changes the last bit of the byte in the image to be the bit of addition image[offset] = (byte)((image[offset] & 0xFE) | b ); } } return image; } /* *Retrieves hidden text from an image *@param image Array of data, representing an image *@return Array of data which contains the hidden text */ private byte[] decode_text(byte[] image,String pass2) {String k = "5qw8sd4h"; int length1 = 0; int length2=0; int offset2=64; //loop through 32 bytes of data to determine text length for(int i=0; i<32; ++i) //i=24 will also work, as only the 4th byte contains real data { length1 = (length1 << 1) | (image[i] & 1); } for(int i=32; i<64; ++i) //i=24 will also work, as only the 4th byte contains real data { length2 = (length2 << 1) | (image[i] & 1); } length1=length1-length2; byte[] pass4 = new byte[length2];

36

byte[] result = new byte[length1]; for(int b=0; b<pass4.length; ++b ) { //loop through each bit within a byte of text for(int i=0; i<8; ++i, ++offset2) { //assign bit: [(new byte value) << 1] OR [(text byte) AND 1] pass4[b] = (byte)((pass4[b] << 1) | (image[offset2] & 1)); } } byte[] dec = DES.decrypt(pass4, k.getBytes()); if(pass2.equals(new String(dec))) //loop through each byte of text {for(int b=0; b<result.length; ++b ) { //loop through each bit within a byte of text for(int i=0; i<8; ++i, ++offset2) { //assign bit: [(new byte value) << 1] OR [(text byte) AND 1] result[b] = (byte)((result[b] << 1) | (image[offset2] & 1)); } } return result;} else { JOptionPane.showMessageDialog(null, "password is wrong","Error",JOptionPane.ERROR_MESSAGE); return null ; } } }

DES.java file
public class DES { // initial permuation table private static int[] IP = { 58, 50, 42, 34, 26, 18, 10, 2, 60, 52, 44, 36, 28, 20, 12, 4, 62, 54, 46, 38, 30, 22, 14, 6, 64, 56, 48, 40, 32, 24, 16, 8, 57, 49, 41, 33, 25, 17, 9, 1, 59, 51, 43, 35, 27, 19, 11, 3, 61, 53, 45, 37, 29, 21, 13, 5, 63, 55, 47, 39, 31, 23, 15, 7 }; // inverse initial permutation private static int[] invIP = { 40, 8, 48, 16, 56, 24, 64, 32, 39, 7, 47, 15, 55, 23, 63, 31, 38, 6, 46, 14, 54, 22, 62, 30, 37, 5, 45, 13, 53, 21, 61, 29, 36, 4, 44, 12, 52, 20, 60, 28, 35, 3, 43, 11, 51, 19, 59, 27, 34, 2, 42, 10, 50, 18, 58, 26, 33, 1, 41, 9, 49, 17, 57, 25 }; // Permutation P (in f(Feistel) function) private static int[] P = { 16, 7, 20, 21, 29, 12, 28, 17, 1, 15, 23, 26, 5, 18, 31, 10, 2, 8, 24, 14, 32, 27, 3, 9, 19, 13, 30, 6, 22, 11, 4, 25 }; // initial key permutation 64 => 56 biti private static int[] PC1 = { 57, 49, 41, 33, 25, 17, 9, 1, 58, 50, 42, 34, 26, 18, 10, 2, 59, 51, 43, 35, 27, 19, 11, 3, 60, 52, 44, 36, 63,

37

55, 47, 39, 31, 23, 15, 7, 62, 54, 46, 38, 30, 22, 14, 6, 61, 53, 45, 37, 29, 21, 13, 5, 28, 20, 12, 4 }; // key permutation at round i 56 => 48 private static int[] PC2 = { 14, 17, 11, 24, 1, 5, 3, 28, 15, 6, 21, 10, 23, 19, 12, 4, 26, 8, 16, 7, 27, 20, 13, 2, 41, 52, 31, 37, 47, 55, 30, 40, 51, 45, 33, 48, 44, 49, 39, 56, 34, 53, 46, 42, 50, 36, 29, 32 }; // key shift for each round private static int[] keyShift = { 1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1 }; // expansion permutation from function f private static int[] expandTbl = { 32, 1, 2, 3, 4, 5, 4, 5, 6, 7, 8, 9, 8, 9, 10, 11, 12, 13, 12, 13, 14, 15, 16, 17, 16, 17, 18, 19, 20, 21, 20, 21, 22, 23, 24, 25, 24, 25, 26, 27, 28, 29, 28, 29, 30, 31, 32, 1 }; // substitution boxes private static int[][][] sboxes = { { { 14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7 }, { 0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8 }, { 4, 1, 14, 8, 13, 6, 2, 11, 15, 12, 9, 7, 3, 10, 5, 0 }, { 15, 12, 8, 2, 4, 9, 1, 7, 5, 11, 3, 14, 10, 0, 6, 13 } }, { { 15, 1, 8, 14, 6, 11, 3, 2, 9, 7, 2, 13, 12, 0, 5, 10 }, { 3, 13, 4, 7, 15, 2, 8, 14, 12, 0, 1, 10, 6, 9, 11, 5 }, { 0, 14, 7, 11, 10, 4, 13, 1, 5, 8, 12, 6, 9, 3, 2, 15 }, { 13, 8, 10, 1, 3, 15, 4, 2, 11, 6, 7, 12, 0, 5, 14, 9 } }, { { 10, 0, 9, 14, 6, 3, 15, 5, 1, 13, 12, 7, 11, 4, 2, 8 }, { 13, 7, 0, 9, 3, 4, 6, 10, 2, 8, 5, 14, 12, 11, 15, 1 }, { 13, 6, 4, 9, 8, 15, 3, 0, 11, 1, 2, 12, 5, 10, 14, 7 }, { 1, 10, 13, 0, 6, 9, 8, 7, 4, 15, 14, 3, 11, 5, 2, 12 } }, { { 7, 13, 14, 3, 0, 6, 9, 10, 1, 2, 8, 5, 11, 12, 4, 15 }, { 13, 8, 11, 5, 6, 15, 0, 3, 4, 7, 2, 12, 1, 10, 14, 9 }, { 10, 6, 9, 0, 12, 11, 7, 13, 15, 1, 3, 14, 5, 2, 8, 4 }, { 3, 15, 0, 6, 10, 1, 13, 8, 9, 4, 5, 11, 12, 7, 2, 14 } }, { { 2, 12, 4, 1, 7, 10, 11, 6, 8, 5, 3, 15, 13, 0, 14, 9 }, { 14, 11, 2, 12, 4, 7, 13, 1, 5, 0, 15, 10, 3, 9, 8, 6 }, { 4, 2, 1, 11, 10, 13, 7, 8, 15, 9, 12, 5, 6, 3, 0, 14 }, { 11, 8, 12, 7, 1, 14, 2, 12, 6, 15, 0, 9, 10, 4, 5, 3 } }, { { 12, 1, 10, 15, 9, 2, 6, 8, 0, 13, 3, 4, 14, 7, 5, 11 }, { 10, 15, 4, 2, 7, 12, 9, 5, 6, 1, 13, 14, 0, 11, 3, 8 }, { 9, 14, 15, 5, 2, 8, 12, 3, 7, 0, 4, 10, 1, 13, 11, 6 }, { 4, 3, 2, 12, 9, 5, 15, 10, 11, 14, 1, 7, 6, 0, 8, 13 } }, {

{ 4, 11, 2, 14, 15, 0, 8, 13, 3, 12, 9, 7, 5, 10, 6, 1 }, { 13, 0, 11, 7, 4, 9, 1, 10, 14, 3, 5, 12, 2, 15, 8, 6 }, { 1, 4, 11, 13, 12, 3, 7, 14, 10, 15, 6, 8, 0, 5, 9, 2 }, { 6, 11, 13, 8, 1, 4, 10, 7, 9, 5, 0, 15, 14, 2, 3, 12 }

}, {

{ 13, 2, 8, 4, 6, 15, 11, 1, 10, 9, 3, 14, 5, 0, 12, 7 }, { 1, 15, 13, 8, 10, 3, 7, 4, 12, 5, 6, 11, 0, 14, 9, 2 },

38

{ 7, 11, 4, 1, 9, 12, 14, 2, 0, 6, 10, 13, 15, 3, 5, 8 }, { 2, 1, 14, 7, 4, 10, 18, 13, 15, 12, 9, 0, 3, 5, 6, 11 } } }; // holds subkeys(3 because we'll implement triple DES also private static byte[][] K; private static byte[][] K1; private static byte[][] K2;

private static void setBit(byte[] data, int pos, int val) { int posByte = pos / 8; int posBit = pos % 8; byte tmpB = data[posByte]; tmpB = (byte) (((0xFF7F >> posBit) & tmpB) & 0x00FF); byte newByte = (byte) ((val << (8 - (posBit + 1))) | tmpB); data[posByte] = newByte; } private static int extractBit(byte[] data, int pos) { int posByte = pos / 8; int posBit = pos % 8; byte tmpB = data[posByte]; int bit = tmpB >> (8 - (posBit + 1)) & 0x0001; return bit; } private static byte[] rotLeft(byte[] input, int len, int pas) { int nrBytes = (len - 1) / 8 + 1; byte[] out = new byte[nrBytes]; for (int i = 0; i < len; i++) { int val = extractBit(input, (i + pas) % len); setBit(out, i, val); } return out; } private static byte[] extractBits(byte[] input, int pos, int n) { int numOfBytes = (n - 1) / 8 + 1; byte[] out = new byte[numOfBytes]; for (int i = 0; i < n; i++) { int val = extractBit(input, pos + i); setBit(out, i, val); } return out; } private static byte[] permutFunc(byte[] input, int[] table) { int nrBytes = (table.length - 1) / 8 + 1;

39

byte[] out = new byte[nrBytes]; for (int i = 0; i < table.length; i++) { int val = extractBit(input, table[i] - 1); setBit(out, i, val); } return out; } private static byte[] xor_func(byte[] a, byte[] b) { byte[] out = new byte[a.length]; for (int i = 0; i < a.length; i++) { out[i] = (byte) (a[i] ^ b[i]); } return out; } private static byte[] encrypt64Bloc(byte[] bloc,byte[][] subkeys, boolean isDecrypt) { byte[] tmp = new byte[bloc.length]; byte[] R = new byte[bloc.length / 2]; byte[] L = new byte[bloc.length / 2]; tmp = permutFunc(bloc, IP); L = extractBits(tmp, 0, IP.length/2); R = extractBits(tmp, IP.length/2, IP.length/2); for (int i = 0; i < 16; i++) { byte[] tmpR = R; if(isDecrypt) R = f_func(R, subkeys[15-i]); else R = f_func(R,subkeys[i]); R = xor_func(L, R); L = tmpR; } tmp = concatBits(R, IP.length/2, L, IP.length/2); tmp = permutFunc(tmp, invIP); return tmp; } private static byte[] f_func(byte[] R, byte[] K) { byte[] tmp; tmp = permutFunc(R, expandTbl); tmp = xor_func(tmp, K); tmp = s_func(tmp); tmp = permutFunc(tmp, P); return tmp; } private static byte[] s_func(byte[] in) {

40

in = separateBytes(in, 6); byte[] out = new byte[in.length / 2]; int halfByte = 0; for (int b = 0; b < in.length; b++) { byte valByte = in[b]; int r = 2 * (valByte >> 7 & 0x0001) + (valByte >> 2 & 0x0001); int c = valByte >> 3 & 0x000F; int val = sboxes[b][r][c]; if (b % 2 == 0) halfByte = val; else out[b / 2] = (byte) (16 * halfByte + val); } return out; } private static byte[] separateBytes(byte[] in, int len) { int numOfBytes = (8 * in.length - 1) / len + 1; byte[] out = new byte[numOfBytes]; for (int i = 0; i < numOfBytes; i++) { for (int j = 0; j < len; j++) { int val = extractBit(in, len * i + j); setBit(out, 8 * i + j, val); } } return out; } private static byte[] concatBits(byte[] a, int aLen, byte[] b, int bLen) { int numOfBytes = (aLen + bLen - 1) / 8 + 1; byte[] out = new byte[numOfBytes]; int j = 0; for (int i = 0; i < aLen; i++) { int val = extractBit(a, i); setBit(out, j, val); j++; } for (int i = 0; i < bLen; i++) { int val = extractBit(b, i); setBit(out, j, val); j++; } return out; }

private static byte[] deletePadding(byte[] input) { int count = 0; int i = input.length - 1; while (input[i] == 0) { count++; i--; }

41

byte[] tmp = new byte[input.length - count - 1]; System.arraycopy(input, 0, tmp, 0, tmp.length); return tmp; }

private static byte[][] generateSubKeys(byte[] key) { byte[][] tmp = new byte[16][]; byte[] tmpK = permutFunc(key, PC1); byte[] C = extractBits(tmpK, 0, PC1.length/2); byte[] D = extractBits(tmpK, PC1.length/2, PC1.length/2); for (int i = 0; i < 16; i++) { C = rotLeft(C, 28, keyShift[i]); D = rotLeft(D, 28, keyShift[i]); byte[] cd = concatBits(C, 28, D, 28); tmp[i] = permutFunc(cd, PC2); } return tmp; } public static byte[] encrypt(byte[] data, byte[] key) { int lenght=0; byte[] padding = new byte[1]; int i; lenght = 8 - data.length % 8; padding = new byte[lenght]; padding[0] = (byte) 0x80; for (i = 1; i < lenght; i++) padding[i] = 0; byte[] tmp = new byte[data.length + lenght]; byte[] bloc = new byte[8]; K = generateSubKeys(key); int count = 0; for (i = 0; i < data.length + lenght; i++) { if (i > 0 && i % 8 == 0) { bloc = encrypt64Bloc(bloc,K, false); System.arraycopy(bloc, 0, tmp, i - 8, bloc.length); } if (i < data.length) bloc[i % 8] = data[i]; else{ bloc[i % 8] = padding[count % 8];

42

count++; } } if(bloc.length == 8){ bloc = encrypt64Bloc(bloc,K, false); System.arraycopy(bloc, 0, tmp, i - 8, bloc.length); } return tmp; }

public static byte[] decrypt(byte[] data, byte[] key) { int i; byte[] tmp = new byte[data.length]; byte[] bloc = new byte[8]; K = generateSubKeys(key); for (i = 0; i < data.length; i++) { if (i > 0 && i % 8 == 0) { bloc = encrypt64Bloc(bloc,K, true); System.arraycopy(bloc, 0, tmp, i - 8, bloc.length); } if (i < data.length) bloc[i % 8] = data[i]; } bloc = encrypt64Bloc(bloc,K, true); System.arraycopy(bloc, 0, tmp, i - 8, bloc.length);

tmp = deletePadding(tmp); return tmp; } }

43

10. Conclusion:
Project has been completed and functioning properly with the provided properties. Encryption and Compression is independent of each other. Feature enables the users to filter the features as needed. Steganography implemented allows the user to create new file if main file is not to be modified. Security of the system has been done through password. Various levels of compression can be implemented. All features implemented are as per user requirements. GUI designed in Java is user friendly. Only a batch file is there that ca be executed to execute the source code which is not possible through any other software. Basic Software requirements are simple and dont require much hardware. Project completed as per the features in all respects.

11. Future Enhancements:


1) Other Encryption techniques can also be implemented 2) A combination of text and file can also be implemented 3) Authentication of user using this software can also be done using passwords for security in the organization 4) A more user friendly environment can also be created but that will hamper the system memory requirements

44

12. References
1) http://orlingrabbe.com/des.htm 2) http://www.javabeginner.com/java-swing/java-%20swing-tutorial 3) http://www.apl.jhu.edu/~hall/java/Swing-Tutorial/Swing-Tutorial-Intro.html

4) Java: The Complete Reference by Herbert Schildt 5) http://www.java2s.com/Tutorial/Java/0240__Swing/Catalog0240__Swing.htm 6) http://en.wikipedia.org/wiki/Least_significant_bit

45

Você também pode gostar