Sunday, March 27, 2011
RSA Keygen GUI
So I have been developing over the past few days a console version of a RSA keygen. I completed it (but have not had it validated by others - but I assume it works properly, as a demo - and possible actual keygen given long enough values).
But now I have started using the NetBeans IDE (which by the way, sucks compared to Eclipse). I have started using the Swing library to create it with the Netbeans GUI builder, which is nice, and pretty simple to use. It took me only a few minutes to design my interface.
In a GUI though, they make it so much different. In this picture to the left, there is many things going on. take the 'p' line for instance.
When you click on P, it gives you a cursor. You can type anything you want, like '2354jqw;elkrj234;5klj'. When focus is lost on the p line, it performs an event called FocusLost. There are many events like FocusLost, FocusGained, mouseover, etc. This makes it easy to create it without having to compare the mouse to the actual object on the screen. It also makes it a pain to do.
Whenever the focus is lost on p, it runs a method that strips everything out except for digits. If there isn't anything left, it just holds "", or nothing (but not null - just an empty string).
This is the easy part. However, when all 3 values are filled, and you click 'validate', it updates the values to RSA spec (actually, only 'probably' - method for finding long prime numbers may or may not work entirely. We assume that it is.)
It works mostly. It does in fact create public and private key files, so it does work. However, writing files doesn't work (yet - it should be a pretty easy upgrade to port from the console version)
It also has some issues with event handling.
I have a variable called privatekey - a string, which holds the private key (a big integer). It only needs to be held as a string since we won't be doing anything with the biginteger form.The problem is that there is no event that is executed (I think) as you type. So I need to now update the fields which no longer makes the current private key up-to-date, so you lose the private key and have to revalidate, and recreate.
Yes, it is a pain sort of. I have devised a new structure of how to handle events and will be testing it soon.
All this programming is... meh... i have been programming for about 3 days straight now. It has been so... taxing.
Posted by Mike Perez at 9:32 PM