Skip to content

Instantly share code, notes, and snippets.

@cbscribe
Created April 28, 2021 21:22
Show Gist options
  • Save cbscribe/a5f7e4ed97d29fde0cf55738056fda78 to your computer and use it in GitHub Desktop.
Save cbscribe/a5f7e4ed97d29fde0cf55738056fda78 to your computer and use it in GitHub Desktop.
Find a value for D (RSA algorithm)
# This program finds a value for D in the RSA algorithm
# Given values for A and E
A = int(input("A: "))
E = int(input("E: "))
# Start at E so D will be bigger
n = E
while True:
n += 1
D = (n * A + 1) / E
if D.is_integer() and D != E:
break
D = int(D)
print(f"Found D: {D}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment