Skip to content

Commit

Permalink
Merge pull request #256 from djv554/main
Browse files Browse the repository at this point in the history
Added an encryption and decryption app
  • Loading branch information
UTSAVS26 authored Oct 8, 2024
2 parents 9d5aa55 + dd6c9ad commit 29a7dee
Show file tree
Hide file tree
Showing 4 changed files with 117 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Beginner_Projects/Number Guessing Game/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## **Password Generator**
## **Number Guessing Game**

### 🎯 **Goal**

Expand Down Expand Up @@ -41,4 +41,4 @@ N/A.
In conclusion, this Number Guessing Game project demonstrates fundamental programming concepts such as random number generation, user input handling, loops, and error handling in Python. It provides an engaging, interactive experience where users can repeatedly guess until they find the correct number, offering immediate feedback. The code is simple yet effective, making it a great learning project for beginner developers looking to strengthen their understanding of basic programming logic.

**Deanne Vaz**
[GitHub](https://github.com/djv554) | | [LinkedIn](https://www.linkedin.com/in/deanne-vaz/)
[GitHub](https://github.com/djv554) | | [LinkedIn](https://www.linkedin.com/in/deanne-vaz/)
2 changes: 1 addition & 1 deletion Beginner_Projects/Web Scraper/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## **Password Generator**
## **Web Scraper**

### 🎯 **Goal**

Expand Down
42 changes: 42 additions & 0 deletions Cybersecurity_Tools/Encryption_Decryption app/README.md
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 Cybersecurity_Tools/Encryption_Decryption app/encrypt_decrypt.py
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}")

0 comments on commit 29a7dee

Please sign in to comment.