Results 1 to 4 of 4

Thread: How Do I....?

  1. #1
    Lyricid is offline Member
    Join Date
    Nov 2009
    Posts
    28
    Rep Power
    0

    Exclamation How Do I....?

    How do i convert the following output into a integer?

    i am basically creating the public key and private key for a rsa encryption and decryption class, when i print my public key and private key i always get something like this:

    Encrypt@8a0544 - This is the Public Key (Need to display as number)

    and

    Decrypt@5e2ccd - This is the Private Key ( need to display as a number)

    any clues guys? if you need the whole code let me know

    The line of code is:

    Java Code:
       /**
        * Create a RSA object for a public key holder,
        * with just e and n.
        */
       
       public Encrypt(long public_e, long public_n) {
           e = public_e;
           n = public_n;
            
       }
    and in my main part

    Java Code:
    Encrypt A = new Encrypt(e, n); // Public Key
    Last edited by Lyricid; 03-11-2010 at 09:27 PM.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Do you need to give your Encrypt and Decrypt classes public String toString() overrides?

  3. #3
    Lyricid is offline Member
    Join Date
    Nov 2009
    Posts
    28
    Rep Power
    0

    Default

    they are in two seperate classes i have uploaded the code its very simple not too long...have a look as see if you can assist me please....
    Attached Files Attached Files

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by Lyricid View Post
    they are in two seperate classes i have uploaded the code its very simple not too long...have a look as see if you can assist me please....
    I'll pass on looking at their code, but it looks like you're calling (either directly or indirectly) toString on Encrypt and Decrypt objects, such as would happen if you did

    Java Code:
    Encrypt myEncrypt = new Encrypt(e, n);
    System.out.println(myEncrypt);
    If you give Encrypt a decent toString override, or else print out the two numbers of the key via whatever getter methods that are available, this could make more sense:

    Java Code:
    Encrypt myEncrypt = new Encrypt(e, n);
    System.out.println(myEncrypt.getPublic_e() + ", " + myEncrypt.getPublic_n());

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •