


from __future__ import annotations
def        UpperCAmelCase_      (							__snake_case  ,		__snake_case		)  ->    str:







     """simple docstring"""


     _lowercase   ,					_lowercase   ,					_lowercase							   ='''''', '''''', ''''''
     _lowercase							   =[]

     for character in message_part:
          tmp.append(character_to_number[character]		)

     for each in tmp:
          one += each[0]
          two += each[1]
          three += each[2]

     return one + two + three
def        UpperCAmelCase_      (							__snake_case  ,		__snake_case		)  ->    tuple[str, str, str]:







     """simple docstring"""


     _lowercase   ,					_lowercase							   ='''''', ''''''
     _lowercase							   =[]

     for character in message_part:
          this_part += character_to_number[character]

     for digit in this_part:
          tmp += digit
          if len(__snake_case		) == len(__snake_case		):
               result.append(__snake_case		)
               _lowercase							   =''''''

     return result[0], result[1], result[2]
def        UpperCAmelCase_      (							__snake_case  ,		__snake_case		)  ->    tuple[str, str, dict[str, str], dict[str, str]]:







     """simple docstring"""


     _lowercase							   =alphabet.replace(''' '''  ,		''''''		).upper()
     _lowercase							   =message.replace(''' '''  ,		''''''		).upper()

     # Check length and characters
     if len(__snake_case		) != 27:
          raise KeyError('''Length of alphabet has to be 27.'''		)
     for each in message:
          if each not in alphabet:
               raise ValueError('''Each message character has to be included in alphabet!'''		)

                # Generate dictionares
     _lowercase							   =(
         '''111''',
         '''112''',
         '''113''',
         '''121''',
         '''122''',
         '''123''',
         '''131''',
         '''132''',
         '''133''',
         '''211''',
         '''212''',
         '''213''',
         '''221''',
         '''222''',
         '''223''',
         '''231''',
         '''232''',
         '''233''',
         '''311''',
         '''312''',
         '''313''',
         '''321''',
         '''322''',
         '''323''',
         '''331''',
         '''332''',
         '''333''',
     )
     _lowercase							   ={}
     _lowercase							   ={}
     for letter, number in zip(__snake_case  ,		__snake_case		):
          _lowercase							   =number
          _lowercase							   =letter

     return message, alphabet, character_to_number, number_to_character
def        UpperCAmelCase_      (							__snake_case  ,		__snake_case = "ABCDEFGHIJKLMNOPQRSTUVWXYZ."  ,		__snake_case = 5		)  ->    str:







     """simple docstring"""


     _lowercase   ,					_lowercase   ,					_lowercase   ,					_lowercase							   =__prepare(
         __snake_case  ,		__snake_case		)
     _lowercase   ,					_lowercase							   ='''''', ''''''

     for i in range(0  ,		len(__snake_case		) + 1  ,		__snake_case		):
          encrypted_numeric += __encrypt_part(
              message[i : i + period]  ,		__snake_case		)

     for i in range(0  ,		len(__snake_case		)  ,		3		):
          encrypted += number_to_character[encrypted_numeric[i : i + 3]]

     return encrypted
def        UpperCAmelCase_      (							__snake_case  ,		__snake_case = "ABCDEFGHIJKLMNOPQRSTUVWXYZ."  ,		__snake_case = 5		)  ->    str:







     """simple docstring"""


     _lowercase   ,					_lowercase   ,					_lowercase   ,					_lowercase							   =__prepare(
         __snake_case  ,		__snake_case		)
     _lowercase							   =[]
     _lowercase							   =''''''

     for i in range(0  ,		len(__snake_case		) + 1  ,		__snake_case		):
          _lowercase   ,					_lowercase   ,					_lowercase							   =__decrypt_part(message[i : i + period]  ,		__snake_case		)

          for j in range(0  ,		len(__snake_case		)		):
               decrypted_numeric.append(a[j] + b[j] + c[j]		)

     for each in decrypted_numeric:
          decrypted += number_to_character[each]

     return decrypted


if __name__ == "__main__":
  UpperCAmelCase__     			=							'''DEFEND THE EAST WALL OF THE CASTLE.'''
  UpperCAmelCase__     			=							encrypt_message(msg, '''EPSDUCVWYM.ZLKXNBTFGORIJHAQ''')
  UpperCAmelCase__     			=							decrypt_message(encrypted, '''EPSDUCVWYM.ZLKXNBTFGORIJHAQ''')
  print(f'''Encrypted: {encrypted}\nDecrypted: {decrypted}''')





import requests

try:
  from django.contrib.auth import authenticate, login
  from django.shortcuts import redirect, render
except ImportError:
  UpperCAmelCase__     			=							UpperCAmelCase__     			=							UpperCAmelCase__     			=							UpperCAmelCase__     			=							print
def        UpperCAmelCase_      (							__snake_case		)  ->    List[str]:







 """simple docstring"""


 _lowercase							   ='''secretKey'''
 _lowercase							   ='''https://www.google.com/recaptcha/api/siteverify'''

 # when method is not POST, direct user to login page
 if request.method != "POST":
  return render(__snake_case  ,		'''login.html'''		)

 # from the frontend, get username, password, and client_key
 _lowercase							   =request.POST.get('''username'''		)
 _lowercase							   =request.POST.get('''password'''		)
 _lowercase							   =request.POST.get('''g-recaptcha-response'''		)

 # post recaptcha response to Google's recaptcha api
 _lowercase							   =requests.post(__snake_case  ,		data={'''secret''': secret_key, '''response''': client_key}		)
 # if the recaptcha api verified our keys
 if response.json().get('''success'''  ,		__snake_case		):
  # authenticate the user
  _lowercase							   =authenticate(__snake_case  ,		username=__snake_case  ,		password=__snake_case		)
  if user_in_database:
   login(__snake_case  ,		__snake_case		)
   return redirect('''/your-webpage'''		)
 return render(__snake_case  ,		'''login.html'''		)

