
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 (		)		-> None:
		print('Making key files...' )
		make_key_files('rsa' ,    1024 )
		print('Key files generation successful.' )



def   __SCREAMING_SNAKE_CASE (		SCREAMING_SNAKE_CASE )		-> tuple[tuple[int, int], tuple[int, int]]:
		print('Generating prime p...' )
		SCREAMING_SNAKE_CASE_					:	Optional[int]		  =			rabinMiller.generate_large_prime(SCREAMING_SNAKE_CASE_ )
		print('Generating prime q...' )
		SCREAMING_SNAKE_CASE_					:	Tuple		  =			rabinMiller.generate_large_prime(SCREAMING_SNAKE_CASE_ )
		SCREAMING_SNAKE_CASE_					:	Any		  =			p * q

		print('Generating e that is relatively prime to (p - 1) * (q - 1)...' )
		while True:
				SCREAMING_SNAKE_CASE_					:	str		  =			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...' )
		SCREAMING_SNAKE_CASE_					:	List[Any]		  =			cryptoMath.find_mod_inverse(SCREAMING_SNAKE_CASE_ ,    (p - 1) * (q - 1) )

		SCREAMING_SNAKE_CASE_					:	Optional[Any]		  =			(n, e)
		SCREAMING_SNAKE_CASE_					:	List[Any]		  =			(n, d)
		return (public_key, private_key)



def   __SCREAMING_SNAKE_CASE (		SCREAMING_SNAKE_CASE ,    SCREAMING_SNAKE_CASE )		-> None:







		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_					:	Dict		  =			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()













from dataclasses import dataclass, field
from typing import ClassVar, Dict

from ..features import Features, Value
from .base import TaskTemplate




@dataclass(frozen=A__    )
class 			__UpperCamelCase    (							A__    ):
     __A	:  str							  =   field(default="""language-modeling"""	, metadata={"""include_in_asdict_even_if_is_default""": True}    )

     __A	:  ClassVar[Features]							  =   Features({"""text""": Value("""string"""    )}    )
     __A	:  ClassVar[Features]							  =   Features({}    )
     __A	:  str							  =   "text"





     @property
     def 		UpperCamelCase(     self					):
        return {self.text_column: "text"}