




'''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 		__magic_name__    (	)		->					None:

					'''simple docstring'''

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


def 		__magic_name__    (	__UpperCAmelCase	)		->					tuple[tuple[int, int], tuple[int, int]]:

					'''simple docstring'''

					print('''Generating prime p...'''	)
					snake_case_									=				rabinMiller.generate_large_prime(lowerCAmelCase_	)
					print('''Generating prime q...'''	)
					snake_case_									=				rabinMiller.generate_large_prime(lowerCAmelCase_	)
					snake_case_									=				p * q

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

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

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


def 		__magic_name__    (	__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()

					snake_case_									=				generate_key(lowerCAmelCase_	)
					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()





import warnings

from ...utils import logging
from .image_processing_chinese_clip import ChineseCLIPImageProcessor


_UpperCAmelCase	:     Any   =logging.get_logger(__name__)







class  snake_case__(							UpperCAmelCase__							):







						'''simple docstring'''




						def __init__( self      ,  *__lowercase      ,  **__lowercase							)    ->			None:
										warnings.warn(
										    '''The class ChineseCLIPFeatureExtractor is deprecated and will be removed in version 5 of Transformers.'''
										    ''' Please use ChineseCLIPImageProcessor instead.'''      ,  __lowercase      ,  )
										super().__init__(*__lowercase      ,  **__lowercase							)