|
-
Urgent! What is wrong with this program? Part 1
Please, i am writing a project on implementation of Rivest-Shamir-Adleman(RSA) algorithm on local area network(LAN).But the JAVA program i wrote refused to work. please, can anyone help me with this.The program is given below is only a part of the entire program due to space constraint. The remain program will be sent in the next post.Thanks
Code:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.lang.*;
public class My_RSA extends JFrame {
private Container container;
private JFrame iFrame,jFrame, kFrame;
private GridBagLayout layout;
private GridBagConstraints constraints;
private JTextField nField, dField;
private JTextArea messageArea, cypherArea, plainArea,keysArea;
private JScrollPane messagescroll, cypherScroll, plainScroll;
private JButton readButton, sendButton, okButton, cancelButton;
private JPanel jPanel, nPanel,dPanel, okPanel,myPanel, mePanel,
statusPanel, progressPanel,cancelPanel;
private JPanel boardPanel1, boardPanel2, cypherPanel,plainPanel,
messagePanel, readPanel, sendPanel;
private JLabel emptyLabel, jLabel, nLabel, dLabel, dumLabel1, dumLabel2,
statusLabel;
private JLabel emptyLabel1, emptyLabel2 , emptyLabel3, emptyLabel4;
private JPanel emptyPanel, emptyPanel1, emptyPanel2, emptyPanel3,
emptyPanel4;
private String message = "", plaintext = "", cyphertext = "", publish = "";
private long d, e, m, n, p, q;
private final JProgressBar current = new JProgressBar(0, 100);
private KeyGenerator gen;
private Encryption enc;
private Decryption dec;
private Sending go;
public My_RSA()
{
Super("RSA Encryption System");
Container = getContentPane();
layout = new GridBagLayout();
container.setLayout(layout);
constraints = new GridBagConstraints();
gen = new KeyGenerator();
kFrame = new JFrame("Sending...");
mePanel = new JPanel();
mePanel.setLayout(layout);
progressPanel = new JPanel();
progressPanel.add(current);
cancelPanel = new JPanel();
statusPanel = new JPanel();
statusPanel = new JLabel(" From A to B");
statusPanel.add(statusLabel);
cancelButton = new JButton("cancel");
cancelButton.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent event)
{
Current.setValue(0);
kFrame.setVisible(false);
}
}
);
Current.setSize(100, 5);
cancelPanel.add(cancelButton);
emptyLabel1 = new JLabel("");
emptyLabel2 = new JLabel("");
emptyLabel3 = new JLabel("");
emptyLabel4 = new JLabel("");
emptyPanel1 = new JPanel();
emptyPanel2 = new JPanel();
emptyPanel3 = new JPanel();
emptyPanel4= new JPanel();
readPanel = new JPanel();
sendPanel = new JPanel();
messagePanel = new JPanel();
cypherPanel = new JPanel();
plainPanel = new JPanel()
boardPanel1 = new JPanel();
boardPanel1.setLayout(new FlowLayout());
boardPanel2 = new JPanel();
boardPanel2.setLayout(new FlowLayout());
messageArea = new JTextArea(5,60);
messageArea.setLineWrap(true);
messageArea.setWrapStyleWord(true);
messageArea.setFont(new Font("Monospaced", Font.PLAIN, 12));
messageArea.setEditable(true);
cypherArea = new JTextArea(20,20);
cypherArea.setLineWrap(true);
cypherArea.setWrapStyleWord(true);
cypherArea.setFont(new Font(" Serif", Font.PLAIN, 12));
cypherArea.setEditable(false);
plainArea = new JTextArea(20,22);
plainArea.setLineWrap(true);
plainArea.setWrapStyleWord(true);
plainArea.setFont(new Font(" Monospaced", Font.PLAIN, 12));
plainArea.setEditable(false);
messageScroll = new JScrollPane(messageArea,
ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEVER);
cypherScroll = new JScrollPane(cypherArea,
ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
plainScroll = new JScrollPane(plainArea,
ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
readButton = new JButton("read>>>");
readButton.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent event)
{
secretKey();
}
}
);
sendButton = new JButton("send");
sendButton.addActionListener(
new ActionListner() {
public void actionPerformed(ActionEvent event)
{
kFrame.setVisible(false);
publish = "";
do {
p = gen.primeNumber();
}while(!(p > 10) || !(p < 26) );
do {
q = gen.primeNumber();
}while( (q <=p) || !((q-p) >2) );
n = p*q;
m = (p-1) * (q-1);
e = gen.coprime(m);
d = gen.find_d(m,e);
message = messageArea.getText();
enc = new Encryption(message);
cyphertext = enc.encrypt(e,n);
publish_Keys();
kFrame.setVisible(true);
go = newSending(cyphertext,kFrame,iFrame,
cypherArea, current, container);
go.start();
kFrame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
container.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
}
}
);
cypherPanel.add(cypherScroll);
cypherPanel.setBorder(BorderFactory.createTitledBorder("cyphertext"));
readPanel.add(readButton);
plainPanel.add(plainScroll);
plainPanel.setBorder(BorderFactory.createTitledBorder("recovered plaintext"));
messagePanel.add(messageScroll);
sendPanel.add(sendButton);
emptyPanel1.add(emptyLabel1);
emptyPanel2.add(emptyLabel2);
emptyPanel3.add(emptyLabel3);
emptyPanel4.add(emptyLabel4);
boardPanel1.add(cypherPanel);
boardPanel1.add(readPanel);
boardPanel1.add(plainPanel);
Similar Threads
-
By jimJohnson in forum Java
Replies: 1
Last Post: 05-04-2008, 11:44 PM
-
By Gipionocheiyort in forum C++
Replies: 1
Last Post: 08-01-2007, 09:44 PM
-
By sedricbenson@ho in forum C++
Replies: 2
Last Post: 11-07-2006, 07:58 AM
-
Replies: 1
Last Post: 06-29-2005, 01:07 AM
-
By W.Pierce in forum VB Classic
Replies: 1
Last Post: 12-11-2001, 08:28 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
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks