Skip to content

Commit d3d4946

Browse files
authored
Added message encoder-decoder
Tech stack py
1 parent 6a96ef5 commit d3d4946

File tree

2 files changed

+65
-0
lines changed

2 files changed

+65
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Message Encoder and Decoder
2+
3+
A web application used to encrypt and decrypt text messages.
4+
- For the encodings listed in RFC 4648, it offers encoding and decoding functions.
5+
6+
## Tech Stack 🛠
7+
![Python](https://img.shields.io/badge/Python-3.9-yellowgreen)
8+
![Streamlit](https://img.shields.io/badge/Streamlit-0.85.1-red)
9+
![base64](https://img.shields.io/badge/-base64-lightgrey)
10+
11+
## Features ⚡
12+
13+
- Encoding and Decoding using Private Key
14+
- Neat and Clean UI
15+
16+
## Demo 👀
17+
18+
[streamlit-app-encode-decode.webm](https://user-images.githubusercontent.com/81156510/183291295-e759eb45-0c1c-4d4e-9f5a-e2f3f95f8a72.webm)
19+
20+
<hr>
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import streamlit as st
2+
import base64
3+
4+
# Function to Encode
5+
6+
def Encode(key, message):
7+
enc=[]
8+
for i in range(len(message)):
9+
key_c = key[i % len(key)]
10+
enc.append(chr((ord(message[i]) + ord(key_c)) % 256))
11+
12+
return base64.urlsafe_b64encode("".join(enc).encode()).decode()
13+
14+
15+
# Function to decode
16+
17+
def Decode(key, message):
18+
dec=[]
19+
message = base64.urlsafe_b64decode(message).decode()
20+
for i in range(len(message)):
21+
key_c = key[i % len(key)]
22+
dec.append(chr((256 + ord(message[i])- ord(key_c)) % 256))
23+
24+
return "".join(dec)
25+
26+
message = st.text_input('Message Text')
27+
28+
key = st.text_input(
29+
"Private key", type="password"
30+
)
31+
32+
mode = st.selectbox(
33+
"What action would you like to perform?",
34+
("Encode", "Decode")
35+
)
36+
37+
if st.button('Result'):
38+
if (mode == "Encode"):
39+
# Encode(key, message)
40+
st.write(Encode(key, message))
41+
else:
42+
st.write(Decode(key, message))
43+
else:
44+
st.write('Please enter all the required information!!')
45+

0 commit comments

Comments
 (0)