I'm working on an RSA cryptosystem, and I want to use a GUI to publish a person's public key.
I have no problem displaying ints / strings via the GUI, but my problem is that the person's public key has an integer that's like 400 digits long, and it's getting chopped off because it can't fit in one horizontal line. How do I make it "roll over" to the next line?
Here's my code:
public class RSA extends JFrame { private String name; // name of the person who owns this cryptosystem private String message; // message to be sent private BigInteger m; // holds message private BigInteger p; // prime 1 private BigInteger q; // prime 2 private BigInteger n; // p*q private BigInteger e; // GCD(e, phi) = 1 private BigInteger d; // relatively prime to e in mod phi private BigInteger c; // Encrypted message private BigInteger phi; // (p-1)*(q-1) public static void main (String[] args) { RSA Alice = new RSASignature("Alice", "message"); RSA Bob = new RSASignature("Bob"); Alice.buildRSA(); // generates e and n for Alice Bob.buildRSA(); // generates e and n for Bob TestFlowLayout frame = new TestFlowLayout(Alice.name, Alice.e, Alice.n, Bob.name, Bob.e, Bob.n); frame.setSize(300,300); frame.setLocationRelativeTo(null); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true);
public class TestFlowLayout extends JFrame { public TestFlowLayout(String name1, BigInteger e1, BigInteger n1, String name2, BigInteger e2, BigInteger n2) { setLayout(new FlowLayout(FlowLayout.LEFT, 100, 200)); add(new JLabel(name1 + "'s public key: (" + e1 + ", " + n1 + ")")); add(new JLabel(name2 + "'s public key: (" + e2 + ", " + n2 + ")")); } }