-
Notifications
You must be signed in to change notification settings - Fork 209
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #256 from djv554/main
Added an encryption and decryption app
- Loading branch information
Showing
4 changed files
with
117 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
## **Password Generator** | ||
## **Web Scraper** | ||
|
||
### 🎯 **Goal** | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
## **Encryption Decryption App** | ||
|
||
### 🎯 **Goal** | ||
|
||
The goal of this project is to create a simple encryption and decryption app using Streamlit. | ||
|
||
### 🧵 **Dataset** | ||
|
||
N/A | ||
|
||
### 🧾 **Description** | ||
|
||
This project is a simple web application built using Streamlit, designed to demonstrate basic encryption and decryption techniques using two well-known algorithms: Caesar Cipher and Vigenère Cipher. | ||
|
||
### 🧮 **What I had done!** | ||
|
||
1. Built a simple, user-friendly Streamlit interface for users to encrypt and decrypt their messages using basic algorithms like Caesar Cipher and Vigenère Cipher. | ||
2. Set up input fields for users to enter messages, select encryption methods, and perform actions (encrypt or decrypt) via buttons and dropdown menus. | ||
|
||
|
||
### 🚀 **Models Implemented** | ||
|
||
N/A | ||
|
||
### 📚 **Libraries Needed** | ||
|
||
1. `Streamlit` - For building the user interface. | ||
|
||
### 📊 **Exploratory Data Analysis Results** | ||
|
||
N/A. | ||
|
||
### 📈 **Performance of the Models based on the Accuracy Scores** | ||
|
||
N/A. | ||
|
||
### 📢 **Conclusion** | ||
|
||
The Basic Encryption and Decryption App serves as an effective introduction to fundamental cryptographic techniques, showcasing the implementation of the Caesar Cipher and Vigenère Cipher. By leveraging Streamlit, the project provides a user-friendly interface that simplifies the process of encrypting and decrypting messages. | ||
|
||
**Deanne Vaz** | ||
[GitHub](https://github.com/djv554) | | [LinkedIn](https://www.linkedin.com/in/deanne-vaz/) |
72 changes: 72 additions & 0 deletions
72
Cybersecurity_Tools/Encryption_Decryption app/encrypt_decrypt.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import streamlit as st | ||
|
||
# Function to encrypt using Caesar Cipher | ||
def caesar_encrypt(plaintext, shift): | ||
encrypted = "" | ||
for char in plaintext: | ||
if char.isalpha(): | ||
shift_amount = shift % 26 | ||
ascii_offset = ord('A') if char.isupper() else ord('a') | ||
encrypted += chr((ord(char) + shift_amount - ascii_offset) % 26 + ascii_offset) | ||
else: | ||
encrypted += char | ||
return encrypted | ||
|
||
# Function to decrypt using Caesar Cipher | ||
def caesar_decrypt(ciphertext, shift): | ||
return caesar_encrypt(ciphertext, -shift) | ||
|
||
# Function to encrypt using Vigenère Cipher | ||
def vignere_encrypt(plaintext, key): | ||
encrypted = "" | ||
key_length = len(key) | ||
for i, char in enumerate(plaintext): | ||
if char.isalpha(): | ||
shift = ord(key[i % key_length].upper()) - ord('A') | ||
ascii_offset = ord('A') if char.isupper() else ord('a') | ||
encrypted += chr((ord(char) + shift - ascii_offset) % 26 + ascii_offset) | ||
else: | ||
encrypted += char | ||
return encrypted | ||
|
||
# Function to decrypt using Vigenère Cipher | ||
def vignere_decrypt(ciphertext, key): | ||
decrypted = "" | ||
key_length = len(key) | ||
for i, char in enumerate(ciphertext): | ||
if char.isalpha(): | ||
shift = ord(key[i % key_length].upper()) - ord('A') | ||
ascii_offset = ord('A') if char.isupper() else ord('a') | ||
decrypted += chr((ord(char) - shift - ascii_offset) % 26 + ascii_offset) | ||
else: | ||
decrypted += char | ||
return decrypted | ||
|
||
# Streamlit app layout | ||
st.title("Basic Encryption and Decryption App") | ||
|
||
message = st.text_area("Enter your message:") | ||
method = st.selectbox("Select encryption/decryption method:", ["Caesar Cipher", "Vigenère Cipher"]) | ||
action = st.selectbox("Select action:", ["Encrypt", "Decrypt"]) | ||
|
||
if method == "Caesar Cipher": | ||
shift = st.number_input("Enter shift value:", min_value=1, value=3) | ||
|
||
if st.button("Submit"): | ||
if action == "Encrypt": | ||
result = caesar_encrypt(message, shift) | ||
st.success(f"Encrypted Message: {result}") | ||
else: | ||
result = caesar_decrypt(message, shift) | ||
st.success(f"Decrypted Message: {result}") | ||
|
||
else: # Vigenère Cipher | ||
key = st.text_input("Enter key:") | ||
|
||
if st.button("Submit"): | ||
if action == "Encrypt": | ||
result = vignere_encrypt(message, key) | ||
st.success(f"Encrypted Message: {result}") | ||
else: | ||
result = vignere_decrypt(message, key) | ||
st.success(f"Decrypted Message: {result}") |