-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
78 lines (69 loc) · 2.15 KB
/
main.py
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
from flask import Flask, render_template, request
import requests
import json
def sifreleulan(karakter,anahtar):
if karakter.isalpha() or karakter.isspace():
message=''
sayi = ord(karakter)
sayi += anahtar
if karakter.isupper():
if sayi > ord('Z'):
sayi -= 26
elif sayi < ord('A'):
sayi += 26
elif karakter.islower():
if sayi > ord('z'):
sayi -= 26
elif sayi < ord('a'):
sayi += 26
message+=chr(sayi)
else:
pass
return message
def cozlan(karakter,anahtar):
message=''
if karakter.isalpha() or karakter.isspace():
sayi = ord(karakter)
sayi -= anahtar
if karakter.isupper():
if sayi > ord('Z'):
sayi -= 26
elif sayi < ord('A'):
sayi += 26
elif karakter.islower():
if sayi > ord('z'):
sayi -= 26
elif sayi < ord('a'):
sayi += 26
message+=chr(sayi)
else:
pass
return message
app = Flask(__name__, static_url_path='/static')
@app.route("/")
def index():
return render_template('index.html')
@app.route("/sifrele/", methods=['GET', 'POST'])
def sifrele():
sifreli_metin=''
if request.method == 'POST':
message = request.form['message']
anahtar = request.form['anahtar']
sifreli_metin=''
for i in message:
sifreli_metin += sifreleulan(i,int(anahtar))
return render_template('sifrele.html', sifreli_metin=sifreli_metin)
@app.route("/desifrele", methods=['GET', 'POST'])
def desifrele():
cozulmus_metin=''
if request.method == 'POST':
sifreli_metin = request.form['message']
anahtar = request.form['anahtar']
for i in sifreli_metin:
cozulmus_metin += cozlan(i,int(anahtar))
return render_template('desifre.html', cozulmus_metin=cozulmus_metin)
if __name__ == "__main__":
app.run()
"""
ENSAR KARABUDAK - github.com/ensarkarabudak
"""