Upload 4 files
Browse files- Procfile +1 -0
- requirements.txt +2 -0
- rsa_app.py +31 -0
- setup.sh +8 -0
Procfile
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
web: sh setup.sh && streamlit run rsa_app.py
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
rsa==4.7.2
|
2 |
+
streamlit==1.12.2
|
rsa_app.py
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import rsa
|
3 |
+
st.write("""
|
4 |
+
# fungsi rsa
|
5 |
+
""")
|
6 |
+
# generate public and private keys with
|
7 |
+
# rsa.newkeys method,this method accepts
|
8 |
+
# key length as its parameter
|
9 |
+
# key length should be atleast 16
|
10 |
+
publicKey, privateKey = rsa.newkeys(512)
|
11 |
+
|
12 |
+
# this is the string that we will be encrypting
|
13 |
+
input = st.text_input('Masukkan Teks', 'Ansine Krisnawati R. Loba')
|
14 |
+
|
15 |
+
# rsa.encrypt method is used to encrypt
|
16 |
+
# string with public key string should be
|
17 |
+
# encode to byte string before encryption
|
18 |
+
# with encode method
|
19 |
+
encMessage = rsa.encrypt(input.encode(),
|
20 |
+
publicKey)
|
21 |
+
|
22 |
+
st.write('enkripsi :', encMessage)
|
23 |
+
|
24 |
+
# the encrypted message can be decrypted
|
25 |
+
# with ras.decrypt method and private key
|
26 |
+
# decrypt method returns encoded byte string,
|
27 |
+
# use decode method to convert it to string
|
28 |
+
# public key cannot be used for decryption
|
29 |
+
decMessage = rsa.decrypt(encMessage, privateKey).decode()
|
30 |
+
|
31 |
+
st.write('dekripsi :', decMessage)
|
setup.sh
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
mkdir -p ~/.streamlit/
|
2 |
+
|
3 |
+
echo "\
|
4 |
+
[server]\n\
|
5 |
+
headless = true\n\
|
6 |
+
enableCORS=false\n\
|
7 |
+
port = $PORT\n\
|
8 |
+
" > ~/.streamlit/config.toml
|