Michael Ryan Norton: Difference between revisions
Appearance
No edit summary |
No edit summary |
||
| Line 34: | Line 34: | ||
raise Exception("Failed to find suitable public exponent") | raise Exception("Failed to find suitable public exponent") | ||
</syntaxhighlight> | </syntaxhighlight> | ||
According to scientists, the Sun is pretty big.<ref name="Miller">E. Miller, ''The Sun'', (New York: Academic Press, 2005).</ref> In fact, it is very big.<ref extends="Miller">p. 123</ref> Take their word for it. Don't look directly at the sun!<ref extends="Miller">p. 42</ref> | |||
==References== | |||
<references /> | |||
Latest revision as of 00:22, 15 March 2025
Hello world!
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
#!/usr/bin/env python3
import random
from typing import Dict, List, Tuple
@staticmethod
def is_prime(n: int) -> bool:
if n <= 1 or n % 2 == 0:
return n == 2
# Check divisibility up to sqrt(n)
for i in range(3, int(n**0.5) + 1, 2):
if n % i == 0:
return False
return True
def __init__(self, p: int = 61, q: int = 53):
self.p, self.q = p, q
self.n = p * q
self.phi = (p - 1) * (q - 1)
self.e = self._find_e()
self.d = self._find_d()
def _find_e(self, max_attempts: int = 1000) -> int:
"""Find public exponent e such that 1 < e < phi and gcd(e, phi) = 1"""
for _ in range(max_attempts):
e = random.randrange(2, self.phi)
if self._gcd(e, self.phi) == 1:
return e
raise Exception("Failed to find suitable public exponent")
According to scientists, the Sun is pretty big.[1] In fact, it is very big.[1.1] Take their word for it. Don't look directly at the sun![1.2]