



import warnings
from collections.abc import Callable
from typing import Any

import numpy
from matplotlib import pyplot

_lowerCamelCase         =	0.2_5 + 0.0j
_lowerCamelCase         =	-0.4 + 0.6j
_lowerCamelCase         =	-0.1 + 0.651j
_lowerCamelCase         =	-2.0
_lowerCamelCase         =	56
_lowerCamelCase         =	2.0
_lowerCamelCase         =	666






def 						_lowerCAmelCase    (					__lowerCamelCase :  complex		,						__lowerCamelCase :  numpy.ndarray  ):



 """simple docstring"""





 return numpy.exp(__lowerCamelCase  ) + c_parameter






def 						_lowerCAmelCase    (					__lowerCamelCase :  complex		,						__lowerCamelCase :  numpy.ndarray  ):



 """simple docstring"""





 return z_values * z_values + c_parameter






def 						_lowerCAmelCase    (					__lowerCamelCase :  float		,						__lowerCamelCase :  int  ):



 """simple docstring"""





 __SCREAMING_SNAKE_CASE							:     List[Any]							=						numpy.linspace(-window_size		,						__lowerCamelCase		,						__lowerCamelCase  )
 __SCREAMING_SNAKE_CASE							:     List[str]							=						x.reshape((nb_pixels, 1)  )
 __SCREAMING_SNAKE_CASE							:     List[Any]							=						numpy.linspace(-window_size		,						__lowerCamelCase		,						__lowerCamelCase  )
 __SCREAMING_SNAKE_CASE							:     str							=						y.reshape((1, nb_pixels)  )
 return x + 1.0j * y






def 						_lowerCAmelCase    (					__lowerCamelCase :  Callable[[Any, numpy.ndarray], numpy.ndarray]		,						__lowerCamelCase :  Any		,						__lowerCamelCase :  int		,						__lowerCamelCase :  numpy.ndarray		,						__lowerCamelCase :  float | None = None		,						):



 """simple docstring"""





 __SCREAMING_SNAKE_CASE							:     Any							=						z_a.astype("complex64"  )
 for _ in range(__lowerCamelCase  ):
  __SCREAMING_SNAKE_CASE							:     List[Any]							=						eval_function(__lowerCamelCase		,						__lowerCamelCase  )
  if infinity is not None:
   numpy.nan_to_num(__lowerCamelCase		,						copy=__lowerCamelCase		,						nan=__lowerCamelCase  )
   __SCREAMING_SNAKE_CASE							:     Any							=						infinity
 return z_n






def 						_lowerCAmelCase    (					__lowerCamelCase :  str		,						__lowerCamelCase :  Any		,						__lowerCamelCase :  float		,						__lowerCamelCase :  numpy.ndarray		,						):



 """simple docstring"""





 __SCREAMING_SNAKE_CASE							:     List[str]							=						(abs(__lowerCamelCase  )).transpose()
 __SCREAMING_SNAKE_CASE							:     str							=						abs_z_final[::-1, :]
 pyplot.matshow(abs_z_final < escape_radius  )
 pyplot.title(F"""Julia set of ${function_label}$, $c={function_params}$"""  )
 pyplot.show()






def 						_lowerCAmelCase    (					):



 """simple docstring"""





 warnings.filterwarnings(
     "ignore"		,						category=__lowerCamelCase		,						message="overflow encountered in multiply"  )
 warnings.filterwarnings(
     "ignore"		,						category=__lowerCamelCase		,						message="invalid value encountered in multiply"		,						)
 warnings.filterwarnings(
     "ignore"		,						category=__lowerCamelCase		,						message="overflow encountered in absolute"  )
 warnings.filterwarnings(
     "ignore"		,						category=__lowerCamelCase		,						message="overflow encountered in exp"  )


if __name__ == "__main__":
      _lowerCamelCase         =	prepare_grid(window_size, nb_pixels)

      ignore_overflow_warnings()  # See file header for explanations

      _lowerCamelCase         =	24
      _lowerCamelCase         =	2 * abs(c_cauliflower) + 1
      _lowerCamelCase         =	iterate_function(
          eval_quadratic_polynomial,
          c_cauliflower,
          nb_iterations,
          z_a,
          infinity=1.1 * escape_radius,
      )
      show_results("""z^2+c""", c_cauliflower, escape_radius, z_final)

      _lowerCamelCase         =	64
      _lowerCamelCase         =	2 * abs(c_polynomial_a) + 1
      _lowerCamelCase         =	iterate_function(
          eval_quadratic_polynomial,
          c_polynomial_a,
          nb_iterations,
          z_a,
          infinity=1.1 * escape_radius,
      )
      show_results("""z^2+c""", c_polynomial_a, escape_radius, z_final)

      _lowerCamelCase         =	161
      _lowerCamelCase         =	2 * abs(c_polynomial_a) + 1
      _lowerCamelCase         =	iterate_function(
          eval_quadratic_polynomial,
          c_polynomial_a,
          nb_iterations,
          z_a,
          infinity=1.1 * escape_radius,
      )
      show_results("""z^2+c""", c_polynomial_a, escape_radius, z_final)

      _lowerCamelCase         =	12
      _lowerCamelCase         =	1_0_0_0_0.0
      _lowerCamelCase         =	iterate_function(
          eval_exponential,
          c_exponential,
          nb_iterations,
          z_a + 2,
          infinity=1.0e1_0,
      )
      show_results("""e^z+c""", c_exponential, escape_radius, z_final)







import random
import sys

from . import cryptomath_module as cryptomath

lowerCAmelCase__      		=					(
    r' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`'
    r'abcdefghijklmnopqrstuvwxyz{|}~'
)






def  __lowerCamelCase						(		lowerCAmelCase__      ,    lowerCAmelCase__      ,    lowerCAmelCase__      ):
       if mode == "encrypt":
              if key_a == 1:
                     sys.exit(
                         'The affine cipher becomes weak when key '
                         'A is set to 1. Choose different key'      )
              if key_b == 0:
                     sys.exit(
                         'The affine cipher becomes weak when key '
                         'B is set to 0. Choose different key'      )
       if key_a < 0 or key_b < 0 or key_b > len(lowerCAmelCase__      ) - 1:
              sys.exit(
                  'Key A must be greater than 0 and key B must '
                  F"""be between 0 and {len(lowerCAmelCase__      ) - 1}."""      )
       if cryptomath.gcd(lowerCAmelCase__      ,    len(lowerCAmelCase__      )      ) != 1:
              sys.exit(
                  F"""Key A {key_a} and the symbol set size {len(lowerCAmelCase__      )} """
                  'are not relatively prime. Choose a different key.'      )






def  __lowerCamelCase						(		lowerCAmelCase__      ,    lowerCAmelCase__      ):
       lowerCAmelCase__      ,   lowerCAmelCase__	      =   divmod(lowerCAmelCase__      ,    len(lowerCAmelCase__      )      )
       check_keys(lowerCAmelCase__      ,    lowerCAmelCase__      ,    'encrypt'      )
       lowerCAmelCase__	      =   ''
       for symbol in message:
              if symbol in SYMBOLS:
                     lowerCAmelCase__	      =   SYMBOLS.find(lowerCAmelCase__      )
                     cipher_text += SYMBOLS[(sym_index * key_a + key_b) % len(lowerCAmelCase__      )]
              else:
                     cipher_text += symbol
       return cipher_text






def  __lowerCamelCase						(		lowerCAmelCase__      ,    lowerCAmelCase__      ):
       lowerCAmelCase__      ,   lowerCAmelCase__	      =   divmod(lowerCAmelCase__      ,    len(lowerCAmelCase__      )      )
       check_keys(lowerCAmelCase__      ,    lowerCAmelCase__      ,    'decrypt'      )
       lowerCAmelCase__	      =   ''
       lowerCAmelCase__	      =   cryptomath.find_mod_inverse(lowerCAmelCase__      ,    len(lowerCAmelCase__      )      )
       for symbol in message:
              if symbol in SYMBOLS:
                     lowerCAmelCase__	      =   SYMBOLS.find(lowerCAmelCase__      )
                     plain_text += SYMBOLS[
                         (sym_index - key_b) * mod_inverse_of_key_a % len(lowerCAmelCase__      )
                     ]
              else:
                     plain_text += symbol
       return plain_text






def  __lowerCamelCase						(		):
       while True:
              lowerCAmelCase__	      =   random.randint(2      ,    len(lowerCAmelCase__      )      )
              lowerCAmelCase__	      =   random.randint(2      ,    len(lowerCAmelCase__      )      )
              if cryptomath.gcd(lowerCAmelCase__      ,    len(lowerCAmelCase__      )      ) == 1 and key_b % len(lowerCAmelCase__      ) != 0:
                     return key_b * len(lowerCAmelCase__      ) + key_b






def  __lowerCamelCase						(		):
       lowerCAmelCase__	      =   input('Enter message: '      ).strip()
       lowerCAmelCase__	      =   int(input('Enter key [2000 - 9000]: '      ).strip()      )
       lowerCAmelCase__	      =   input('Encrypt/Decrypt [E/D]: '      ).strip().lower()

       if mode.startswith('e'      ):
              lowerCAmelCase__	      =   'encrypt'
              lowerCAmelCase__	      =   encrypt_message(lowerCAmelCase__      ,    lowerCAmelCase__      )
       elif mode.startswith('d'      ):
              lowerCAmelCase__	      =   'decrypt'
              lowerCAmelCase__	      =   decrypt_message(lowerCAmelCase__      ,    lowerCAmelCase__      )
       print(F"""\n{mode.title()}ed text: \n{translated}"""      )


if __name__ == "__main__":
    import doctest

    doctest.testmod()
    # main()
