






import os
import random
import sys

from . import cryptomath_module as cryptoMath  # noqa: N812
from . import rabin_miller as rabinMiller  # noqa: N812






def     _snake_case			():
   print('Making key files...')
   make_key_files('rsa'    ,      1024)
   print('Key files generation successful.')






def     _snake_case			(__lowercase):
   print('Generating prime p...')
   UpperCamelCase_									=     rabinMiller.generate_large_prime(_SCREAMING_SNAKE_CASE)
   print('Generating prime q...')
   UpperCamelCase_									=     rabinMiller.generate_large_prime(_SCREAMING_SNAKE_CASE)
   UpperCamelCase_									=     p * q

   print('Generating e that is relatively prime to (p - 1) * (q - 1)...')
   while True:
      UpperCamelCase_									=     random.randrange(2 ** (key_size - 1)    ,      2 ** (key_size))
      if cryptoMath.gcd(_SCREAMING_SNAKE_CASE    ,      (p - 1) * (q - 1)) == 1:
         break

   print('Calculating d that is mod inverse of e...')
   UpperCamelCase_									=     cryptoMath.find_mod_inverse(_SCREAMING_SNAKE_CASE    ,      (p - 1) * (q - 1))

   UpperCamelCase_									=     (n, e)
   UpperCamelCase_									=     (n, d)
   return (public_key, private_key)






def     _snake_case			(__lowercase    ,      __lowercase):
   if os.path.exists(f"""{name}_pubkey.txt""") or os.path.exists(f"""{name}_privkey.txt"""):
      print('\nWARNING:')
      print(
          f"""\"{name}_pubkey.txt\" or \"{name}_privkey.txt\" already exists. \n"""
          'Use a different name or delete these files and re-run this program.')
      sys.exit()

   UpperCamelCase_		,      UpperCamelCase_									=     generate_key(_SCREAMING_SNAKE_CASE)
   print(f"""\nWriting public key to file {name}_pubkey.txt...""")
   with open(f"""{name}_pubkey.txt"""    ,      'w') as out_file:
      out_file.write(f"""{key_size},{public_key[0]},{public_key[1]}""")

   print(f"""Writing private key to file {name}_privkey.txt...""")
   with open(f"""{name}_privkey.txt"""    ,      'w') as out_file:
      out_file.write(f"""{key_size},{private_key[0]},{private_key[1]}""")


if __name__ == "__main__":
 main()













snake_case__      :	List[Any]       	=      """Tobias Carryer"""

from time import time


class 						_a       :






  """simple docstring"""





  def __init__(     self		,		_UpperCAmelCase		,		_UpperCAmelCase		,		_UpperCAmelCase		,		_UpperCAmelCase=int(time() ) )			-> Tuple:  # noqa: B008
     UpperCamelCase_									=     multiplier
     UpperCamelCase_									=     increment
     UpperCamelCase_									=     modulo
     UpperCamelCase_									=     seed




  def    _UpperCAmelCase     (     self )			-> Any:
     UpperCamelCase_									=     (self.multiplier * self.seed + self.increment) % self.modulo
     return self.seed


if __name__ == "__main__":
 # Show the LCG in action.
 snake_case__      :	List[Any]       	=      LinearCongruentialGenerator(1_6_6_4_5_2_5, 1_0_1_3_9_0_4_2_2_3, 2 << 3_1)
 while True:
  print(lcg.next_number())





