Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 889945
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T13:38:53+00:00 2026-05-15T13:38:53+00:00

I’m trying to figure out how to implement RSA crypto from scratch (just for

  • 0

I’m trying to figure out how to implement RSA crypto from scratch (just for the intellectual exercise), and i’m stuck on this point:

For encryption, c = me mod n

Now, e is normally 65537. m and n are 1024-bit integers (eg 128-byte arrays). This is obviously too big for standard methods. How would you implement this?

I’ve been reading a bit about exponentiation here but it just isn’t clicking for me:

Wikipedia-Exponentiation by squaring

This Chapter (see section 14.85)

Thanks.

edit: Also found this – is this more what i should be looking at? Wikipedia- Modular Exponentiation

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T13:38:53+00:00Added an answer on May 15, 2026 at 1:38 pm

    Exponentiation by squaring:

    Let’s take an example. You want to find 1723. Note that 23 is 10111 in binary. Let’s try to build it up from left to right.

               // a      exponent in binary
    
    a = 17     //17^1          1
    
    a = a * a  //17^2         10
    
    a = a * a  //17^4        100
    a = a * 17 //17^5        101
    
    a = a * a  //17^10      1010
    a = a * 17 //17^11      1011
    
    a = a * a  //17^22     10110
    a = a * 17 //17^23     10111
    

    When you square, you double the exponent (shift left by 1 bit). When you multiply by m, you add 1 to the exponent.

    If you want to reduce modulo n, you can do it after each multiplication (rather than leaving it to the end, which would make the numbers get very large).

    65537 is 10000000000000001 in binary which makes all of this pretty easy. It’s basically

    a = m
    repeat 16 times:
        a = a * a
        a = a mod n
    a = a * m
    a = a mod n
    

    where of course a, n and m are “big integers”. a needs to be at least 2048 bits as it can get as large as (n-1)2.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.