



import os
import sys

from . import rsa_key_generator as rkg

a_								=   128
a_								=   256





def 						a__     (						_UpperCamelCase     :	str	,_UpperCamelCase     :	int = DEFAULT_BLOCK_SIZE							):
   __lowerCamelCase  							=      message.encode('''ascii'''							)

   __lowerCamelCase  							=      []
   for block_start in range(0	,len(_UpperCamelCase							)	,_UpperCamelCase							):
      __lowerCamelCase  							=      0
      for i in range(_UpperCamelCase	,min(block_start + block_size	,len(_UpperCamelCase							)							)							):
         block_int += message_bytes[i] * (BYTE_SIZE ** (i % block_size))
      block_ints.append(_UpperCamelCase							)
   return block_ints





def 						a__     (						_UpperCamelCase     :	list[int]	,_UpperCamelCase     :	int	,_UpperCamelCase     :	int = DEFAULT_BLOCK_SIZE							):
   __lowerCamelCase  							=      []
   for block_int in block_ints:
      __lowerCamelCase  							=      []
      for i in range(block_size - 1	,-1	,-1							):
         if len(_UpperCamelCase							) + i < message_length:
            __lowerCamelCase  							=      block_int // (BYTE_SIZE**i)
            __lowerCamelCase  							=      block_int % (BYTE_SIZE**i)
            block_message.insert(0	,chr(_UpperCamelCase							)							)
      message.extend(_UpperCamelCase							)
   return "".join(_UpperCamelCase							)





def 						a__     (						_UpperCamelCase     :	str	,_UpperCamelCase     :	tuple[int, int]	,_UpperCamelCase     :	int = DEFAULT_BLOCK_SIZE							):
   __lowerCamelCase  							=      []
   __lowerCamelCase							,__lowerCamelCase  							=      key

   for block in get_blocks_from_text(_UpperCamelCase	,_UpperCamelCase							):
      encrypted_blocks.append(pow(_UpperCamelCase	,_UpperCamelCase	,_UpperCamelCase							)							)
   return encrypted_blocks





def 						a__     (						_UpperCamelCase     :	list[int]	,_UpperCamelCase     :	int	,_UpperCamelCase     :	tuple[int, int]	,_UpperCamelCase     :	int = DEFAULT_BLOCK_SIZE	,):
   __lowerCamelCase  							=      []
   __lowerCamelCase							,__lowerCamelCase  							=      key
   for block in encrypted_blocks:
      decrypted_blocks.append(pow(_UpperCamelCase	,_UpperCamelCase	,_UpperCamelCase							)							)
   return get_text_from_blocks(_UpperCamelCase	,_UpperCamelCase	,_UpperCamelCase							)





def 						a__     (						_UpperCamelCase     :	str							):
   with open(_UpperCamelCase							) as fo:
      __lowerCamelCase  							=      fo.read()
   __lowerCamelCase							,__lowerCamelCase							,__lowerCamelCase  							=      content.split(''','''							)
   return (int(_UpperCamelCase							), int(_UpperCamelCase							), int(_UpperCamelCase							))





def 						a__     (						_UpperCamelCase     :	str	,_UpperCamelCase     :	str	,_UpperCamelCase     :	str	,_UpperCamelCase     :	int = DEFAULT_BLOCK_SIZE	,):
   __lowerCamelCase							,__lowerCamelCase							,__lowerCamelCase  							=      read_key_file(_UpperCamelCase							)
   if key_size < block_size * 8:
      sys.exit(
          '''ERROR: Block size is {} bits and key size is {} bits. The RSA cipher '''
          '''requires the block size to be equal to or greater than the key size. '''
          '''Either decrease the block size or use different keys.'''.format(
              block_size * 8	,_UpperCamelCase							)							)

   __lowerCamelCase  							=      [str(_UpperCamelCase							) for i in encrypt_message(_UpperCamelCase	,(n, e)	,_UpperCamelCase							)]

   __lowerCamelCase  							=      ''','''.join(_UpperCamelCase							)
   __lowerCamelCase  							=      F"""{len(_UpperCamelCase							)}_{block_size}_{encrypted_content}"""
   with open(_UpperCamelCase	,'''w'''							) as fo:
      fo.write(_UpperCamelCase							)
   return encrypted_content





def 						a__     (						_UpperCamelCase     :	str	,_UpperCamelCase     :	str							):
   __lowerCamelCase							,__lowerCamelCase							,__lowerCamelCase  							=      read_key_file(_UpperCamelCase							)
   with open(_UpperCamelCase							) as fo:
      __lowerCamelCase  							=      fo.read()
   __lowerCamelCase							,__lowerCamelCase							,__lowerCamelCase  							=      content.split('''_'''							)
   __lowerCamelCase  							=      int(_UpperCamelCase							)
   __lowerCamelCase  							=      int(_UpperCamelCase							)

   if key_size < block_size * 8:
      sys.exit(
          '''ERROR: Block size is {} bits and key size is {} bits. The RSA cipher '''
          '''requires the block size to be equal to or greater than the key size. '''
          '''Did you specify the correct key file and encrypted file?'''.format(
              block_size * 8	,_UpperCamelCase							)							)

   __lowerCamelCase  							=      []
   for block in encrypted_message.split(''','''							):
      encrypted_blocks.append(int(_UpperCamelCase							)							)

   return decrypt_message(_UpperCamelCase	,_UpperCamelCase	,(n, d)	,_UpperCamelCase							)





def 						a__     (						):
   __lowerCamelCase  							=      '''encrypted_file.txt'''
   __lowerCamelCase  							=      input(R'''Encrypt\Decrypt [e\d]: '''							)

   if response.lower().startswith('''e'''							):
      __lowerCamelCase  							=      '''encrypt'''
   elif response.lower().startswith('''d'''							):
      __lowerCamelCase  							=      '''decrypt'''

   if mode == "encrypt":
      if not os.path.exists('''rsa_pubkey.txt'''							):
         rkg.make_key_files('''rsa'''	,10_24							)

      __lowerCamelCase  							=      input('''\nEnter message: '''							)
      __lowerCamelCase  							=      '''rsa_pubkey.txt'''
      print(F"""Encrypting and writing to {filename}..."""							)
      __lowerCamelCase  							=      encrypt_and_write_to_file(_UpperCamelCase	,_UpperCamelCase	,_UpperCamelCase							)

      print('''\nEncrypted text:'''							)
      print(_UpperCamelCase							)

   elif mode == "decrypt":
      __lowerCamelCase  							=      '''rsa_privkey.txt'''
      print(F"""Reading from {filename} and decrypting..."""							)
      __lowerCamelCase  							=      read_from_file_and_decrypt(_UpperCamelCase	,_UpperCamelCase							)
      print('''writing decryption to rsa_decryption.txt...'''							)
      with open('''rsa_decryption.txt'''	,'''w'''							) as dec:
         dec.write(_UpperCamelCase							)

      print('''\nDecryption:'''							)
      print(_UpperCamelCase							)


if __name__ == "__main__":
  main()











import platform
from argparse import ArgumentParser

import huggingface_hub
import pandas
import pyarrow

from datasets import __version__ as version
from datasets.commands import BaseDatasetsCLICommand





def 						a__     (						_UpperCamelCase     :	Optional[Any]							):
   return EnvironmentCommand()





class 	__lowerCAmelCase       (		lowerCAmelCase__				):




 @staticmethod
 def     lowerCamelCase (  __UpperCAmelCase			):



    '''simple docstring'''
    __lowerCamelCase  							=      parser.add_parser('''env'''		,			help='''Print relevant system environment info.'''			)
    download_parser.set_defaults(func=__UpperCAmelCase			)




 def     lowerCamelCase (  self			):



    '''simple docstring'''
    __lowerCamelCase  							=      {
        '''`datasets` version''': version,
        '''Platform''': platform.platform(),
        '''Python version''': platform.python_version(),
        '''Huggingface_hub version''': huggingface_hub.__version__,
        '''PyArrow version''': pyarrow.__version__,
        '''Pandas version''': pandas.__version__,
    }

    print('''\nCopy-and-paste the text below in your GitHub issue.\n'''			)
    print(self.format_dict(__UpperCAmelCase			)			)

    return info




 @staticmethod
 def     lowerCamelCase (  __UpperCAmelCase			):



    '''simple docstring'''
    return "\n".join([F"""- {prop}: {val}""" for prop, val in d.items()]			) + "\n"






