Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.gui > #3307 > unrolled thread

Using Java To Implement R

Started by"Soul Tech" <soul.tech@THRWHITE.remove-dii-this>
First post2011-04-27 15:44 +0000
Last post2011-04-27 15:44 +0000
Articles 2 — 2 participants

Back to article view | Back to comp.lang.java.gui


Contents

  Using Java To Implement R "Soul Tech" <soul.tech@THRWHITE.remove-dii-this> - 2011-04-27 15:44 +0000
    Re: Using Java To Impleme "RedGrittyBrick" <redgrittybrick@THRWHITE.remove-dii-this> - 2011-04-27 15:44 +0000

#3307 — Using Java To Implement R

From"Soul Tech" <soul.tech@THRWHITE.remove-dii-this>
Date2011-04-27 15:44 +0000
SubjectUsing Java To Implement R
Message-ID<49cf4399-682f-43ba-8c46-fead35a3d818@u72g2000hsf.googlegroups.com>
  To: comp.lang.java.gui
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 =
{'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};




     public static void main(String[] args) {


          long P3 = 0;
          long P3mod33=0;
          long C7=0;
           long C7mod33=0;



       for(int counter = 0; counter < numeric.length; counter++){

            for(int i = 0; i < StartSymbolic.length; i++)  {

              int temp = numeric[counter];
              P3 = (long) (temp*temp*temp);
         P3mod33 = P3%33;
         C7 = (long)
(P3mod33*P3mod33*P3mod33*P3mod33*P3mod33*P3mod33*P3mod33);
        int tp = numeric[counter];
                 C7mod33 = C7%33;
       }

 
System.out.println("*******************************************");
                     //System.out.println(StartSymbolic[i]);
                    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]);
 
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: 3
P3: 27
P3mod33: 27
C7: 10460353203
C7mod33:3
*******************************************
*******************************************
Numeric: 4
P3: 64
P3mod33: 31
C7: 27512614111
C7mod33:4
*******************************************
*******************************************
Numeric: 5
P3: 125
P3mod33: 26
C7: 8031810176
C7mod33:5
*******************************************
*******************************************
Numeric: 6
P3: 216
P3mod33: 18
C7: 612220032
C7mod33:6
*******************************************
*******************************************
Numeric: 7
P3: 343
P3mod33: 13
C7: 62748517
C7mod33:7
*******************************************
*******************************************
Numeric: 8
P3: 512
P3mod33: 17
C7: 410338673
C7mod33:8
*******************************************
*******************************************
Numeric: 9
P3: 729
P3mod33: 3
C7: 2187
C7mod33:9
*******************************************
*******************************************
Numeric: 10
P3: 1000
P3mod33: 10
C7: 10000000
C7mod33:10
*******************************************
*******************************************
Numeric: 11
P3: 1331
P3mod33: 11
C7: 19487171
C7mod33:11
*******************************************
*******************************************
Numeric: 12
P3: 1728
P3mod33: 12
C7: 35831808
C7mod33:12
*******************************************
*******************************************
Numeric: 13
P3: 2197
P3mod33: 19
C7: 893871739
C7mod33:13
*******************************************
*******************************************
Numeric: 14
P3: 2744
P3mod33: 5
C7: 78125
C7mod33:14
*******************************************
*******************************************
Numeric: 15
P3: 3375
P3mod33: 9
C7: 4782969
C7mod33:15
*******************************************
*******************************************
Numeric: 16
P3: 4096
P3mod33: 4
C7: 16384
C7mod33:16
*******************************************
*******************************************
Numeric: 17
P3: 4913
P3mod33: 29
C7: 17249876309
C7mod33:17
*******************************************
*******************************************
Numeric: 18
P3: 5832
P3mod33: 24
C7: 4586471424
C7mod33:18
*******************************************
*******************************************
Numeric: 19
P3: 6859
P3mod33: 28
C7: 13492928512
C7mod33:19
*******************************************
*******************************************
Numeric: 20
P3: 8000
P3mod33: 14
C7: 105413504
C7mod33:20
*******************************************
*******************************************
Numeric: 21
P3: 9261
P3mod33: 21
C7: 1801088541
C7mod33:21
*******************************************
*******************************************
Numeric: 22
P3: 10648
P3mod33: 22
C7: 2494357888
C7mod33:22
*******************************************
*******************************************
Numeric: 23
P3: 12167
P3mod33: 23
C7: 3404825447
C7mod33:23
*******************************************
*******************************************
Numeric: 24
P3: 13824
P3mod33: 30
C7: 21870000000
C7mod33:24
*******************************************
*******************************************
Numeric: 25
P3: 15625
P3mod33: 16
C7: 268435456
C7mod33:25
*******************************************
*******************************************
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


Thanks.

---
 * 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

[toc] | [next] | [standalone]


#3312 — Re: Using Java To Impleme

From"RedGrittyBrick" <redgrittybrick@THRWHITE.remove-dii-this>
Date2011-04-27 15:44 +0000
SubjectRe: Using Java To Impleme
Message-ID<SomdncpDc8VoY3nanZ2dnUVZ8sijnZ2d@bt.com>
In reply to#3307
  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
> *******************************************

<snip>

> *******************************************
> 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

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.java.gui


csiph-web