Spaces:
Runtime error
Runtime error
nikoirsyad44
commited on
Commit
·
a6255c2
1
Parent(s):
34e85d9
p1
Browse files- Procfile +1 -0
- requirements.txt +2 -0
- setup.sh +7 -0
- ttd dgital.py +43 -0
Procfile
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
web: sh setup.sh && streamlit run fernet.py
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
cryptography==3.4.8
|
2 |
+
streamlit==1.12.2
|
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
|
ttd dgital.py
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import hashlib
|
3 |
+
from cryptography.hazmat.primitives import hashes
|
4 |
+
from cryptography.hazmat.primitives.asymmetric import (
|
5 |
+
padding, rsa, utils
|
6 |
+
)
|
7 |
+
private_key = rsa.generate_private_key(
|
8 |
+
public_exponent=65537,
|
9 |
+
key_size=2048,
|
10 |
+
)
|
11 |
+
|
12 |
+
st.write("""
|
13 |
+
## Tanda Tangan Digital RSA
|
14 |
+
""")
|
15 |
+
input = st.text_input('Masukkan Teks', 'Niko Irsyad')
|
16 |
+
|
17 |
+
prehashed_msg = hashlib.sha256(input.encode()).digest()
|
18 |
+
signature = private_key.sign(
|
19 |
+
prehashed_msg,
|
20 |
+
padding.PSS(
|
21 |
+
mgf=padding.MGF1(hashes.SHA256()),
|
22 |
+
salt_length=padding.PSS.MAX_LENGTH
|
23 |
+
),
|
24 |
+
utils.Prehashed(hashes.SHA256())
|
25 |
+
)
|
26 |
+
|
27 |
+
st.write("Tanda tangan digital :", signature)
|
28 |
+
|
29 |
+
public_key = private_key.public_key()
|
30 |
+
|
31 |
+
try :
|
32 |
+
public_key.verify(
|
33 |
+
signature,
|
34 |
+
prehashed_msg,
|
35 |
+
padding.PSS(
|
36 |
+
mgf=padding.MGF1(hashes.SHA256()),
|
37 |
+
salt_length=padding.PSS.MAX_LENGTH
|
38 |
+
),
|
39 |
+
utils.Prehashed(hashes.SHA256())
|
40 |
+
)
|
41 |
+
st.write('Tanda tangan VALID')
|
42 |
+
except InvalidSignature:
|
43 |
+
st.write('Tanda tangan INVALID')
|