ASCII, RSA AND BIGNUM

Discussion in 'Ruby' started by Barry Sperling, Aug 27, 2004.

  1. Continuing on the track of the previous question about ASCII, I'm using
    each_byte to change a string to ASCII for the purpose of encrypting it,
    using the theory of the RSA algorithm ( to see if I can! ). Part of
    this algorithm requires getting a power ( a**b ) in which the "a" is the
    ASCII value of the string and the "b" is some large number that is
    dictated by the RSA algorithm ( about 25,000,000,000,000 for my test
    string ). However, when I do this I get the error

    NaN
    test_ascii.rbw:20: warning: in a**b, b may be too big

    While I could simulate a power with a loop, doing this 25 trillion times
    might take a little while. I could also simulate the power with logs,
    but I'm sure that this would add inaccuracies and the integral number
    has to be exact. Is there a way out or is this just a fundamental
    limitation of Bignums in Ruby?
    Barry
     
    Barry Sperling, Aug 27, 2004
    #1
    1. Advertising

  2. Barry Sperling

    Markus Guest

    It's a limitation of our universe; there isn't enough matter to store
    numbers that large.

    Instead, look at the algorithm a little more closely and I'm sure you'll
    find that you only need some of the bits out of this humungo number.
    Generally, the algorithm is specified in such a way that you can get
    just what you need.

    If it isn't clear in what you're working from, check out MathWorld or
    Knuth's books (IIRC) for hints. And remember, google is your friend.

    -- MarkusQ


    On Fri, 2004-08-27 at 14:07, Barry Sperling wrote:
    > Continuing on the track of the previous question about ASCII, I'm using
    > each_byte to change a string to ASCII for the purpose of encrypting it,
    > using the theory of the RSA algorithm ( to see if I can! ). Part of
    > this algorithm requires getting a power ( a**b ) in which the "a" is the
    > ASCII value of the string and the "b" is some large number that is
    > dictated by the RSA algorithm ( about 25,000,000,000,000 for my test
    > string ). However, when I do this I get the error
    >
    > NaN
    > test_ascii.rbw:20: warning: in a**b, b may be too big
    >
    > While I could simulate a power with a loop, doing this 25 trillion times
    > might take a little while. I could also simulate the power with logs,
    > but I'm sure that this would add inaccuracies and the integral number
    > has to be exact. Is there a way out or is this just a fundamental
    > limitation of Bignums in Ruby?
    > Barry
    >
     
    Markus, Aug 27, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. gg
    Replies:
    0
    Views:
    2,710
  2. TOXiC
    Replies:
    5
    Views:
    1,259
    TOXiC
    Jan 31, 2007
  3. Replies:
    3
    Views:
    122
    Olivier D.
    Sep 9, 2004
  4. Replies:
    0
    Views:
    137
  5. James O'Brien
    Replies:
    3
    Views:
    255
    Ben Morrow
    Mar 5, 2004
Loading...

Share This Page