

from collections import namedtuple

__A    	=			namedtuple('''from_to''', '''from_ to''')

__A    	=			{
    '''atm''': from_to(1, 1),
    '''pascal''': from_to(0.000_0098, 10_13_25),
    '''bar''': from_to(0.98_6923, 1.0_1325),
    '''kilopascal''': from_to(0.0098_6923, 101.325),
    '''megapascal''': from_to(9.8_6923, 0.10_1325),
    '''psi''': from_to(0.06_8046, 14.6959),
    '''inHg''': from_to(0.033_4211, 29.9213),
    '''torr''': from_to(0.0013_1579, 7_60),
}



def    snake_case_(_UpperCamelCase				, _UpperCamelCase				, _UpperCamelCase  )							->			float:



  """simple docstring"""






  if from_type not in PRESSURE_CONVERSION:
    raise ValueError(
        F"""Invalid 'from_type' value: {from_type!r}  Supported values are:\n"""
        + ''', '''.join(_UpperCamelCase  )  )
  if to_type not in PRESSURE_CONVERSION:
    raise ValueError(
        F"""Invalid 'to_type' value: {to_type!r}.  Supported values are:\n"""
        + ''', '''.join(_UpperCamelCase  )  )
  return (
      value * PRESSURE_CONVERSION[from_type].from_ * PRESSURE_CONVERSION[to_type].to
  )


if __name__ == "__main__":
 import doctest

 doctest.testmod()




import random
import sys

from . import cryptomath_module as cryptomath

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



def    snake_case_(_UpperCamelCase				, _UpperCamelCase				, _UpperCamelCase  )							->			None:



  """simple docstring"""






  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(_UpperCamelCase  ) - 1:
    sys.exit(
        '''Key A must be greater than 0 and key B must '''
        F"""be between 0 and {len(_UpperCamelCase  ) - 1}."""  )
  if cryptomath.gcd(_UpperCamelCase				, len(_UpperCamelCase  )  ) != 1:
    sys.exit(
        F"""Key A {key_a} and the symbol set size {len(_UpperCamelCase  )} """
        '''are not relatively prime. Choose a different key.'''  )



def    snake_case_(_UpperCamelCase				, _UpperCamelCase  )							->			str:



  """simple docstring"""






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



def    snake_case_(_UpperCamelCase				, _UpperCamelCase  )							->			str:



  """simple docstring"""






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



def    snake_case_()							->			int:



  """simple docstring"""






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



def    snake_case_()							->			None:



  """simple docstring"""






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

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


if __name__ == "__main__":
 import doctest

 doctest.testmod()
 # main()

