# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     name: python3
# ---

# + [markdown] id="view-in-github" colab_type="text"
# <a href="https://colab.research.google.com/github/mriceflame/Password-Encryptor-Descryptor/blob/main/MLH_Daily_Challenge_password_encryptor.ipynb" target="_parent"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/></a>

# + colab={"base_uri": "https://localhost:8080/"} id="Jj16tLhUvqQW" outputId="407c09cc-1408-465c-f770-6fead4fa6e24"
# !pip install pycrypto

# + colab={"base_uri": "https://localhost:8080/"} id="NcXt4pqDv9fW" outputId="9b7e2b6e-1339-42a9-d95d-e5e6f2214908"
from Crypto.Cipher import AES #importring AES
from os import urandom #importing OS
import binascii

key = urandom(32)
iv = urandom(16) 
print(key,iv)


# + colab={"base_uri": "https://localhost:8080/"} id="HwD5rHAxwDE5" outputId="8b24f6f4-b732-45dc-c3c2-0d6680f056ba"
############################# ENCRYPTION #######################################
encrypterObj = AES.new(key, AES.MODE_ECB, iv) 
encryptedText = encrypterObj.encrypt(('useDemo password'.encode()))


print('Encrypted Password : ',encryptedText)

# + colab={"base_uri": "https://localhost:8080/"} id="vg5eA994wF4J" outputId="fc089ae9-5ab8-4300-bdaf-cb9c5d93fed2"
############################# DECRYPTION #######################################
decrypterObj = AES.new(key, AES.MODE_ECB, iv)
decryptedText = decrypterObj.decrypt(encryptedText)
decryptedPassword = decryptedText.decode('UTF-8')
print('Decrypted message : ',decryptedText.decode())



# + colab={"base_uri": "https://localhost:8080/"} id="70phYWSkwIlR" outputId="f2ff7998-0894-4fcd-dce6-fb6980aefbfb"
if ('useDemo password' == decryptedPassword):
  print('Password Encrypted and Decrypted Successfully')
else: print('not same')

StarcoderdataJupyterScriptsDedupFiltered