Path: csiph.com!x330-a1.tempe.blueboxinc.net!feeder1.hal-mli.net!news.glorb.com!news-out.readnews.com!transit3.readnews.com!news-out.news.tds.net!newsreading01.news.tds.net!86597e80!not-for-mail From: "RedGrittyBrick" Subject: Re: Using Java To Impleme Message-ID: X-Comment-To: comp.lang.java.gui Newsgroups: comp.lang.java.gui In-Reply-To: <49cf4399-682f-43ba-8c46-fead35a3d818@u72g2000hsf.googlegroups.com> References: <49cf4399-682f-43ba-8c46-fead35a3d818@u72g2000hsf.googlegroups.com> Content-Type: text/plain; charset=IBM437 Content-Transfer-Encoding: 8bit X-Gateway: time.synchro.net [Synchronet 3.15a-Win32 NewsLink 1.92] Lines: 166 Date: Wed, 27 Apr 2011 15:44:08 GMT NNTP-Posting-Host: 96.60.20.240 X-Complaints-To: news@tds.net X-Trace: newsreading01.news.tds.net 1303919048 96.60.20.240 (Wed, 27 Apr 2011 10:44:08 CDT) NNTP-Posting-Date: Wed, 27 Apr 2011 10:44:08 CDT Organization: TDS.net Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.gui:3312 To: comp.lang.java.gui Soul Tech wrote: > Hi I'm looking for SOME advice on how to simulate the following: > > http://i71.photobucket.com/albums/i140/carpinate/RSA.jpg > http://i71.photobucket.com/albums/i140/carpinate/RSA2.jpg > > Ive done this so far: > > package RSAalgorithm; > > public class SecurityAlgorithm { > > public static char[] StartSymbolic = I'd name that variable "letters" or "symbols" rather than "StartSymbolic". > {'A','B','C','D','E','F','G','H','I','J', > > 'K','L','M','N','O','P','Q','R','S','T', > 'U','V','W','X','Y','Z'}; > > public static int[] numeric = > {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, > 16,17,18,19,20,21,22,23,24,25,26}; > Since numeric[n] is always n there is no need for this array. > > > > public static void main(String[] args) { > > > long P3 = 0; > long P3mod33=0; > long C7=0; > long C7mod33=0; There is a convention that variable names should start with a lowercase letter. Please use those conventions when sharing code. Otherwise your variable names look like class names and are confusing. > > > > for(int counter = 0; counter < numeric.length; counter++){ > > for(int i = 0; i < StartSymbolic.length; i++) { If you are attempting to reproduce the "RSA2" table I don't see why you have two for loops, One should suffice. It would be clearer if you used variable names like p instead of counter or i. > > int temp = numeric[counter]; Isn't this the same as int temp = counter; > P3 = (long) (temp*temp*temp); Which makes this P3 = (long) (counter*counter*counter); And if you used my suggestions for naming it would be p3 = p*p*p; which I would find clearer. You don't need the the explicit cast to long. > P3mod33 = P3%33; > C7 = (long) > (P3mod33*P3mod33*P3mod33*P3mod33*P3mod33*P3mod33*P3mod33); > int tp = numeric[counter]; int tp = counter; > C7mod33 = C7%33; > } > The indentation could be improved! Try configuring your editor or IDE to replace tabs with spaces (two or four) > > System.out.println("*******************************************"); > //System.out.println(StartSymbolic[i]); Is it the line above that is causing you difficulty? What happens when you include it? > System.out.println("Numeric: " + > numeric[counter]); > System.out.println("P3: " +P3); > System.out.println("P3mod33: " + P3mod33); > System.out.println("C7: " +C7); > System.out.println("C7mod33:" + C7mod33); > // System.out.println(StartSymbolic[i]); Shouldn't that be System.out.println(StartSymbolic[C7mod33]); > > System.out.println("*******************************************"); > > } > > } > } > > > > > Output: > ******************************************* > Numeric: 1 > P3: 1 > P3mod33: 1 > C7: 1 > C7mod33:1 > ******************************************* > ******************************************* > Numeric: 2 > P3: 8 > P3mod33: 8 > C7: 2097152 > C7mod33:2 > ******************************************* > ******************************************* > Numeric: 26 > P3: 17576 > P3mod33: 20 > C7: 1280000000 > C7mod33:26 > ******************************************* > > I was looking to achieve what is shown in the 1st image. > > I can get the numeric, P3, P3mod33, C7, C7mod33 to print out but not > the symbolic information for some reason? > > I want to be able to allow the user to enter in a string then the > plaintext and ciphertext can be displayed. > > Like this: > String input: SUZANNE > Output: > Plaintext: S U Z A N N E > Ciphertext: 28 21 20 1 5 5 26 > That isn't RSA. That is seven separate RSA-like messages. That would be using RSA to produce a trivial substitution cipher. Followup set to comp.lang.java.help since the problems are not with the GUI. --- * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet! --- Synchronet 3.15a-Win32 NewsLink 1.92 Time Warp of the Future BBS - telnet://time.synchro.net:24