



'''simple docstring'''





import os
import random
import sys

from . import cryptomath_module as cryptomath
from . import rabin_miller

A					:       int									=     3
def 						_a       (    lowerCamelCase_				):
   print('''Generating primitive root of p'''				)
   while True:
      snake_case       :				List[Any]		    =random.randrange(3	,		__lowerCamelCase				)
      if pow(__lowerCamelCase	,		2	,		__lowerCamelCase				) == 1:
         continue
      if pow(__lowerCamelCase	,		__lowerCamelCase	,		__lowerCamelCase				) == 1:
         continue
      return g
def 						_a       (    lowerCamelCase_				):
   print('''Generating prime p...'''				)
   snake_case       :				Tuple		    =rabin_miller.generate_large_prime(__lowerCamelCase				)  # select large prime number.
   snake_case       :				List[str]		    =primitive_root(__lowerCamelCase				)  # one primitive root on modulo p.
   snake_case       :				Union[str, Any]		    =random.randrange(3	,		__lowerCamelCase				)  # private_key -> have to be greater than 2 for safety.
   snake_case       :				Any		    =cryptomath.find_mod_inverse(pow(__lowerCamelCase	,		__lowerCamelCase	,		__lowerCamelCase				)	,		__lowerCamelCase				)

   snake_case       :				Tuple		    =(key_size, e_a, e_a, p)
   snake_case       :				Tuple		    =(key_size, d)

   return public_key, private_key
def 						_a       (    lowerCamelCase_	,		lowerCamelCase_				):




   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       :				Optional[Any]		    =generate_key(__lowerCamelCase				)
   print(F'''\nWriting public key to file {name}_pubkey.txt...'''				)
   with open(F'''{name}_pubkey.txt'''	,		'''w'''				) as fo:
      fo.write(F'''{public_key[0]},{public_key[1]},{public_key[2]},{public_key[3]}'''				)

   print(F'''Writing private key to file {name}_privkey.txt...'''				)
   with open(F'''{name}_privkey.txt'''	,		'''w'''				) as fo:
      fo.write(F'''{private_key[0]},{private_key[1]}'''				)
def 						_a       (    ):
   print('''Making key files...'''				)
   make_key_files('''elgamal'''	,		20_48				)
   print('''Key files generation successful'''				)


if __name__ == "__main__":
      main()









'''simple docstring'''






import inspect
import re
from hashlib import shaaaa
from typing import Dict, List

from .arrow import arrow
from .audiofolder import audiofolder
from .csv import csv
from .imagefolder import imagefolder
from .json import json
from .pandas import pandas
from .parquet import parquet
from .sql import sql  # noqa F401
from .text import text





def lowerCamelCase__     (		__lowerCamelCase			:				List[str]				):







   '''simple docstring'''




   _UpperCAmelCase  :  int				       =[]
   for line in lines:
      _UpperCAmelCase  :  Dict				       =re.sub(R'#.*'			,       ''			,       __lowerCamelCase				)  # remove comments
      if line:
         filtered_lines.append(__lowerCamelCase				)
   _UpperCAmelCase  :  str				       ='\n'.join(__lowerCamelCase				)

   # Make a hash from all this code
   _UpperCAmelCase  :  str				       =full_str.encode('utf-8'				)
   return shaaaa(__lowerCamelCase				).hexdigest()


# get importable module names and hash for caching
lowercase				={
    'csv': (csv.__name__, _hash_python_lines(inspect.getsource(csv).splitlines())),
    'json': (json.__name__, _hash_python_lines(inspect.getsource(json).splitlines())),
    'pandas': (pandas.__name__, _hash_python_lines(inspect.getsource(pandas).splitlines())),
    'parquet': (parquet.__name__, _hash_python_lines(inspect.getsource(parquet).splitlines())),
    'arrow': (arrow.__name__, _hash_python_lines(inspect.getsource(arrow).splitlines())),
    'text': (text.__name__, _hash_python_lines(inspect.getsource(text).splitlines())),
    'imagefolder': (imagefolder.__name__, _hash_python_lines(inspect.getsource(imagefolder).splitlines())),
    'audiofolder': (audiofolder.__name__, _hash_python_lines(inspect.getsource(audiofolder).splitlines())),
}

# Used to infer the module to use based on the data files extensions
lowercase				={
    '.csv': ('csv', {}),
    '.tsv': ('csv', {'sep': '\t'}),
    '.json': ('json', {}),
    '.jsonl': ('json', {}),
    '.parquet': ('parquet', {}),
    '.arrow': ('arrow', {}),
    '.txt': ('text', {}),
}
_EXTENSION_TO_MODULE.update({ext: ('imagefolder', {}) for ext in imagefolder.ImageFolder.EXTENSIONS})
_EXTENSION_TO_MODULE.update({ext.upper(): ('imagefolder', {}) for ext in imagefolder.ImageFolder.EXTENSIONS})
_EXTENSION_TO_MODULE.update({ext: ('audiofolder', {}) for ext in audiofolder.AudioFolder.EXTENSIONS})
_EXTENSION_TO_MODULE.update({ext.upper(): ('audiofolder', {}) for ext in audiofolder.AudioFolder.EXTENSIONS})
lowercase				={'imagefolder', 'audiofolder'}

# Used to filter data files based on extensions given a module name
lowercase				={}
for _ext, (_module, _) in _EXTENSION_TO_MODULE.items():
 _MODULE_TO_EXTENSIONS.setdefault(_module, []).append(_ext)

_MODULE_TO_EXTENSIONS["imagefolder"].append('.zip')




_MODULE_TO_EXTENSIONS["audiofolder"].append('.zip')

