File size: 916 Bytes
6b0a772
 
 
 
 
 
 
 
 
 
 
 
 
 
142abd8
6b0a772
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import rsa
import streamlit as st


st.write("""
# RSA
""")
# generate public and private keys with
# rsa.newkeys method,this method accepts
# key length as its parameter
# key length should be atleast 16
publicKey, privateKey = rsa.newkeys(512)

# this is the string that we will be encrypting
input = st.text_input('Masukkan Teks', 'Niko Irsyad Maulana 20220044')

# rsa.encrypt method is used to encrypt
# string with public key string should be
# encode to byte string before encryption
# with encode method
encMessage = rsa.encrypt(input.encode(),
						publicKey)
st.write('enkripsi :', encMessage)

# the encrypted message can be decrypted
# with ras.decrypt method and private key
# decrypt method returns encoded byte string,
# use decode method to convert it to string
# public key cannot be used for decryption
decMessage = rsa.decrypt(encMessage, privateKey).decode()

st.write('dekripsi :', decMessage)