
import os
import random
import sys

from . import cryptomath_module as cryptoMath  # noqa: N812
from . import rabin_miller as rabinMiller  # noqa: N812
def    SCREAMING_SNAKE_CASE__		( )    ->   Tuple:







							"""simple docstring"""






							print('Making key files...'							)
							make_key_files('rsa'       ,1024							)
							print('Key files generation successful.'							)
def    SCREAMING_SNAKE_CASE__		( lowerCAmelCase_				:			Union[str, Any]							)    ->   Union[str, Any]:







							"""simple docstring"""






							print('Generating prime p...'							)
							SCREAMING_SNAKE_CASE_	:							Tuple											=rabinMiller.generate_large_prime(_A							)
							print('Generating prime q...'							)
							SCREAMING_SNAKE_CASE_	:							List[Any]											=rabinMiller.generate_large_prime(_A							)
							SCREAMING_SNAKE_CASE_	:							int											=p * q

							print('Generating e that is relatively prime to (p - 1) * (q - 1)...'							)
							while True:
														SCREAMING_SNAKE_CASE_	:							Union[str, Any]											=random.randrange(2 ** (key_size - 1)       ,2 ** (key_size)							)
														if cryptoMath.gcd(_A       ,(p - 1) * (q - 1)							) == 1:
																					break

							print('Calculating d that is mod inverse of e...'							)
							SCREAMING_SNAKE_CASE_	:							List[Any]											=cryptoMath.find_mod_inverse(_A       ,(p - 1) * (q - 1)							)

							SCREAMING_SNAKE_CASE_	:							Optional[int]											=(n, e)
							SCREAMING_SNAKE_CASE_	:							List[Any]											=(n, d)
							return (public_key, private_key)
def    SCREAMING_SNAKE_CASE__		( lowerCAmelCase_				:			Tuple       ,lowerCAmelCase_				:			Any							)    ->   Any:







							"""simple docstring"""






							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()

							SCREAMING_SNAKE_CASE_				,     SCREAMING_SNAKE_CASE_	:							List[str]											=generate_key(_A							)
							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()






from typing import TYPE_CHECKING

from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


SCREAMING_SNAKE_CASE			:						Optional[int]				  =		{
    """configuration_mctct""": ["""MCTCT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """MCTCTConfig"""],
    """feature_extraction_mctct""": ["""MCTCTFeatureExtractor"""],
    """processing_mctct""": ["""MCTCTProcessor"""],
}


try:
  if not is_torch_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  SCREAMING_SNAKE_CASE			:						Optional[Any]				  =		[
      """MCTCT_PRETRAINED_MODEL_ARCHIVE_LIST""",
      """MCTCTForCTC""",
      """MCTCTModel""",
      """MCTCTPreTrainedModel""",
  ]


if TYPE_CHECKING:
  from .configuration_mctct import MCTCT_PRETRAINED_CONFIG_ARCHIVE_MAP, MCTCTConfig
  from .feature_extraction_mctct import MCTCTFeatureExtractor
  from .processing_mctct import MCTCTProcessor

  try:
    if not is_torch_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_mctct import MCTCT_PRETRAINED_MODEL_ARCHIVE_LIST, MCTCTForCTC, MCTCTModel, MCTCTPreTrainedModel

else:
  import sys

  SCREAMING_SNAKE_CASE			:						Union[str, Any]				  =		_LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)


