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

  • SEARCH
  • Home
  • 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 7076429
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:17:50+00:00 2026-05-28T06:17:50+00:00

I have two numbers, p , and q . I know that I can

  • 0

I have two numbers, p, and q. I know that I can get phi = (p-1)*(q-1) and that ed = 1 (mod phi)… but I’m not sure I get what this means.

I wrote some Python:

p = NUM
q = NUM
e = NUM
phi = (p-1)*(q-1)
d = (1 % phi)/float(e)

But I always get a decimal, and d is supposed to be an integer. what am I doing wrong?

EDIT: I may just not understand RSA. Right now, I’m looking at this page: http://www.di-mgt.com.au/rsa_alg.html

  • 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-28T06:17:51+00:00Added an answer on May 28, 2026 at 6:17 am

    Your understanding of the math is wrong. The equation

    ed ≡ 1 (mod φ)

    means that, the remainder of number ed dividing φ is equal to 1, i.e. in terms of Python,

    >>> (e*d) % phi
    1
    

    For instance, if φ = (7 – 1)(11 – 1) = 60, and e = 17, then if we choose d = 53, then we’ll get

    >>> e = 17
    >>> d = 53
    >>> phi = 60
    >>> (e*d) % phi
    1
    

    We call d a modular multiplicative inverse of e.

    To generate d from e and φ, usually extended Euclidean algorithm is used. Please read http://en.wikipedia.org/wiki/Modular_multiplicative_inverse or https://stackoverflow.com/search?q=python+%22multiplicative+inverse%22&submit=search for more info

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

Sidebar

Related Questions

This question may have been asked already - but unfortunately, I could not find
Say that I have two models- Users and Accounts. Each account can have at
I have a table with two columns (id, numberslist). How can I get all
I have an array that store data. If I subtract two arrays I get
I think this is not really possible but worth asking anyway. Say I have
Say I have two sequences of numbers, A and B . How can I
I have two forms. First one is to decide button numbers by using jslider.
I have a file in which each line contains two numbers. The problem is
I have the following code to generate two random numbers var attackRoll = Math.floor((Math.random()*6)+1);
I have a program where I am generating two double numbers by adding several

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.