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