'''simple docstring'''





import os
import random
import sys

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




						'''simple docstring'''
						print("Making key files..."					)
						make_key_files("rsa"     ,1_0_2_4					)
						print("Key files generation successful."					)
def 						__A							(     UpperCAmelCase					)     ->			tuple[tuple[int, int], tuple[int, int]]:




						'''simple docstring'''
						print("Generating prime p..."					)
						_UpperCamelCase			:			Optional[int]   			=						rabinMiller.generate_large_prime(UpperCAmelCase					)
						print("Generating prime q..."					)
						_UpperCamelCase			:			Any   			=						rabinMiller.generate_large_prime(UpperCAmelCase					)
						_UpperCamelCase			:			str   			=						p * q

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

						print("Calculating d that is mod inverse of e..."					)
						_UpperCamelCase			:			str   			=						cryptoMath.find_mod_inverse(UpperCAmelCase     ,(p - 1) * (q - 1)					)

						_UpperCamelCase			:			Optional[Any]   			=						(n, e)
						_UpperCamelCase			:			int   			=						(n, d)
						return (public_key, private_key)
def 						__A							(     UpperCAmelCase     ,UpperCAmelCase					)     ->			None:




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

						_UpperCamelCase			,       _UpperCamelCase			:			Dict   			=						generate_key(UpperCAmelCase					)
						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()



'''simple docstring'''





from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_sentencepiece_available,
    is_speech_available,
    is_tf_available,
    is_torch_available,
)


lowerCAmelCase_	:		Any			=     {
    """configuration_speech_to_text""": ["""SPEECH_TO_TEXT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """Speech2TextConfig"""],
    """processing_speech_to_text""": ["""Speech2TextProcessor"""],
}

try:
			if not is_sentencepiece_available():
						raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
			pass
else:
			lowerCAmelCase_	:		int			=     ["""Speech2TextTokenizer"""]

try:
			if not is_speech_available():
						raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
			pass
else:
			lowerCAmelCase_	:		Optional[Any]			=     ["""Speech2TextFeatureExtractor"""]

try:
			if not is_tf_available():
						raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
			pass
else:
			lowerCAmelCase_	:		Optional[int]			=     [
			    """TF_SPEECH_TO_TEXT_PRETRAINED_MODEL_ARCHIVE_LIST""",
			    """TFSpeech2TextForConditionalGeneration""",
			    """TFSpeech2TextModel""",
			    """TFSpeech2TextPreTrainedModel""",
			]

try:
			if not is_torch_available():
						raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
			pass
else:
			lowerCAmelCase_	:		str			=     [
			    """SPEECH_TO_TEXT_PRETRAINED_MODEL_ARCHIVE_LIST""",
			    """Speech2TextForConditionalGeneration""",
			    """Speech2TextModel""",
			    """Speech2TextPreTrainedModel""",
			]


if TYPE_CHECKING:
			from .configuration_speech_to_text import SPEECH_TO_TEXT_PRETRAINED_CONFIG_ARCHIVE_MAP, SpeechaTextConfig
			from .processing_speech_to_text import SpeechaTextProcessor

			try:
						if not is_sentencepiece_available():
									raise OptionalDependencyNotAvailable()
			except OptionalDependencyNotAvailable:
						pass
			else:
						from .tokenization_speech_to_text import SpeechaTextTokenizer

			try:
						if not is_speech_available():
									raise OptionalDependencyNotAvailable()
			except OptionalDependencyNotAvailable:
						pass
			else:
						from .feature_extraction_speech_to_text import SpeechaTextFeatureExtractor

			try:
						if not is_tf_available():
									raise OptionalDependencyNotAvailable()
			except OptionalDependencyNotAvailable:
						pass
			else:
						from .modeling_tf_speech_to_text import (
						    TF_SPEECH_TO_TEXT_PRETRAINED_MODEL_ARCHIVE_LIST,
						    TFSpeechaTextForConditionalGeneration,
						    TFSpeechaTextModel,
						    TFSpeechaTextPreTrainedModel,
						)

			try:
						if not is_torch_available():
									raise OptionalDependencyNotAvailable()
			except OptionalDependencyNotAvailable:
						pass
			else:
						from .modeling_speech_to_text import (
						    SPEECH_TO_TEXT_PRETRAINED_MODEL_ARCHIVE_LIST,
						    SpeechaTextForConditionalGeneration,
						    SpeechaTextModel,
						    SpeechaTextPreTrainedModel,
						)

else:
			import sys

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


