CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2015
    Posts
    1

    Handling large exponents in Csharp

    I have this line in an encryption software I'm trying to write:
    enc = (ulong)((Math.Pow(raw, e)) % n);
    However it seems it's not calculating correctly, probably because the exponents are too large.
    For example, 65^17 % 3233 should yield 2790. However my program is giving me 887. What's the best way to simplify the exponent into a more manageable number?

  2. #2
    Join Date
    Mar 2002
    Location
    Portsmouth, UK
    Posts
    121

    Re: Handling large exponents in Csharp

    I've seen code that handles 40 / 128 / 256 bit integers to implement encryption. The code includes routines that implement the maths on the huge integer types.

    .Net framework has a cryptology model http://msdn.microsoft.com/en-us/libr...v=vs.110).aspx

    If you want to implement yourself - look here first - http://www.efgh.com/software/rsa.htm Its c++ but will give you an idea of how to go about it....

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured