Unsupported Page Added
This commit is contained in:
parent
3195c2c689
commit
b267e81b4a
|
@ -27,40 +27,43 @@ def encode():
|
|||
|
||||
@app.route("/encoding", methods=['POST'])
|
||||
def encoding():
|
||||
file = request.files['origin']
|
||||
b2c = [int(x) for x in request.form.getlist("b2c")]
|
||||
# b2c = [int(request.form['b2c'])]
|
||||
payload = request.form['payload']
|
||||
try:
|
||||
file = request.files['origin']
|
||||
b2c = [int(x) for x in request.form.getlist("b2c")]
|
||||
# b2c = [int(request.form['b2c'])]
|
||||
payload = request.form['payload']
|
||||
|
||||
if file.filename != "":
|
||||
file.save(WORKING_PATH + file.filename)
|
||||
if file.filename != "":
|
||||
file.save(WORKING_PATH + file.filename)
|
||||
|
||||
file_extension = os.path.splitext(file.filename)[1]
|
||||
if file_extension == ".png" or file_extension == ".bmp":
|
||||
steg = img_steg.img_steg(WORKING_PATH + file.filename, b2c).encode(payload)
|
||||
cv2.imwrite(WORKING_PATH + "encoded_" + file.filename, steg)
|
||||
session['image'] = file.filename
|
||||
session['image2'] = "encoded_" + file.filename
|
||||
elif file_extension == ".wav":
|
||||
steg = wav_steg.wav_steg(WORKING_PATH + file.filename, b2c).encode(payload)
|
||||
file_extension = os.path.splitext(file.filename)[1]
|
||||
if file_extension == ".png" or file_extension == ".bmp":
|
||||
steg = img_steg.img_steg(WORKING_PATH + file.filename, b2c).encode(payload)
|
||||
cv2.imwrite(WORKING_PATH + "encoded_" + file.filename, steg)
|
||||
session['image'] = file.filename
|
||||
session['image2'] = "encoded_" + file.filename
|
||||
elif file_extension == ".wav":
|
||||
steg = wav_steg.wav_steg(WORKING_PATH + file.filename, b2c).encode(payload)
|
||||
|
||||
# Write encoded data to file
|
||||
new_wav_file = wave.open(WORKING_PATH + "encoded_" + file.filename, "wb")
|
||||
new_wav_file.setnchannels(steg["num_channels"])
|
||||
new_wav_file.setsampwidth(steg["sample_width"])
|
||||
new_wav_file.setframerate(steg["frame_rate"])
|
||||
new_wav_file.writeframes(steg["num_frames"])
|
||||
new_wav_file.close()
|
||||
session['wav'] = file.filename
|
||||
session['wav2'] = "encoded_" + file.filename
|
||||
elif file_extension == ".txt":
|
||||
encoded_data = txt_steg.txt_steg(WORKING_PATH + file.filename, b2c).encode(payload)
|
||||
with open(os.path.join(WORKING_PATH, "encoded_" + file.filename), "w") as f:
|
||||
f.write(encoded_data)
|
||||
session['txt'] = file.filename
|
||||
session['txt2'] = "encoded_" + file.filename
|
||||
# Write encoded data to file
|
||||
new_wav_file = wave.open(WORKING_PATH + "encoded_" + file.filename, "wb")
|
||||
new_wav_file.setnchannels(steg["num_channels"])
|
||||
new_wav_file.setsampwidth(steg["sample_width"])
|
||||
new_wav_file.setframerate(steg["frame_rate"])
|
||||
new_wav_file.writeframes(steg["num_frames"])
|
||||
new_wav_file.close()
|
||||
session['wav'] = file.filename
|
||||
session['wav2'] = "encoded_" + file.filename
|
||||
elif file_extension == ".txt":
|
||||
encoded_data = txt_steg.txt_steg(WORKING_PATH + file.filename, b2c).encode(payload)
|
||||
with open(os.path.join(WORKING_PATH, "encoded_" + file.filename), "w") as f:
|
||||
f.write(encoded_data)
|
||||
session['txt'] = file.filename
|
||||
session['txt2'] = "encoded_" + file.filename
|
||||
|
||||
return redirect("/encode_result")
|
||||
return redirect("/encode_result")
|
||||
except:
|
||||
return redirect("/unsupported")
|
||||
|
||||
@app.route('/encode_result')
|
||||
def encode_result():
|
||||
|
@ -76,26 +79,29 @@ def decode():
|
|||
|
||||
@app.route("/decoding", methods=['POST'])
|
||||
def decoding():
|
||||
file = request.files['encoded_file']
|
||||
b2c = [int(x) for x in request.form.getlist("b2c")]
|
||||
if file.filename != "":
|
||||
file.save(WORKING_PATH + file.filename)
|
||||
try:
|
||||
file = request.files['encoded_file']
|
||||
b2c = [int(x) for x in request.form.getlist("b2c")]
|
||||
if file.filename != "":
|
||||
file.save(WORKING_PATH + file.filename)
|
||||
|
||||
file_extension = os.path.splitext(file.filename)[1]
|
||||
if file_extension == ".png" or file_extension == ".bmp":
|
||||
payload = img_steg.img_steg(WORKING_PATH + file.filename, b2c).decode()
|
||||
session["payload"] = payload
|
||||
session["image"] = file.filename
|
||||
elif file_extension == ".wav":
|
||||
payload = wav_steg.wav_steg(WORKING_PATH + file.filename, b2c).decode()
|
||||
session["payload"] = payload
|
||||
session["wav"] = file.filename
|
||||
elif file_extension == ".txt":
|
||||
payload = txt_steg.txt_steg(WORKING_PATH + file.filename, b2c).decode()
|
||||
session["payload"] = payload
|
||||
session["txt"] = file.filename
|
||||
file_extension = os.path.splitext(file.filename)[1]
|
||||
if file_extension == ".png" or file_extension == ".bmp":
|
||||
payload = img_steg.img_steg(WORKING_PATH + file.filename, b2c).decode()
|
||||
session["payload"] = payload
|
||||
session["image"] = file.filename
|
||||
elif file_extension == ".wav":
|
||||
payload = wav_steg.wav_steg(WORKING_PATH + file.filename, b2c).decode()
|
||||
session["payload"] = payload
|
||||
session["wav"] = file.filename
|
||||
elif file_extension == ".txt":
|
||||
payload = txt_steg.txt_steg(WORKING_PATH + file.filename, b2c).decode()
|
||||
session["payload"] = payload
|
||||
session["txt"] = file.filename
|
||||
|
||||
return redirect("/decode_result")
|
||||
return redirect("/decode_result")
|
||||
except:
|
||||
return redirect("/unsupported")
|
||||
|
||||
@app.route('/decode_result')
|
||||
def decode_result():
|
||||
|
@ -104,6 +110,10 @@ def decode_result():
|
|||
else:
|
||||
return redirect("/decode")
|
||||
|
||||
@app.route('/unsupported')
|
||||
def unsupported():
|
||||
return render_template('unsupported.html')
|
||||
|
||||
@app.route('/get_session')
|
||||
def get_session():
|
||||
session_data = dict(session)
|
||||
|
|
|
@ -8,6 +8,11 @@
|
|||
<title>Decode</title>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.4/jquery.min.js"></script>
|
||||
<style>
|
||||
* {
|
||||
padding: 0px;
|
||||
margin: 0px;
|
||||
}
|
||||
|
||||
.drop-zone {
|
||||
background-color: #f8f8f8;
|
||||
border: 2px dashed #cccccc;
|
||||
|
@ -55,7 +60,8 @@
|
|||
color: white;
|
||||
cursor: pointer;
|
||||
}
|
||||
table{
|
||||
|
||||
table {
|
||||
width: 400px;
|
||||
margin: 10px auto;
|
||||
}
|
||||
|
@ -63,8 +69,10 @@
|
|||
</head>
|
||||
|
||||
<body>
|
||||
<a style="text-decoration: none; color: white; display: inline-block; padding: 14px 16px; background-color: gray;" href="/">< Back</a>
|
||||
|
||||
<div class="form-container">
|
||||
<form action="/decoding" method="POST" enctype = "multipart/form-data">
|
||||
<form action="/decoding" method="POST" enctype="multipart/form-data">
|
||||
<div class="drop-zone" id="dropZone">
|
||||
<div class="upload-icon">⇩</div>
|
||||
<div class="upload-text">Drag and drop an image here or click to browse</div>
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
<title>RESULT</title>
|
||||
</head>
|
||||
<body>
|
||||
<a style="text-decoration: none; color: white; display: inline-block; padding: 14px 16px; background-color: gray;" href="/decode">< Back</a>
|
||||
</body>
|
||||
<script>
|
||||
|
||||
|
@ -16,29 +17,29 @@
|
|||
$.get('/get_session', function(response) {
|
||||
if(response.hasOwnProperty("image")){
|
||||
console.log(response)
|
||||
var html_content = `<section>
|
||||
<div>
|
||||
<h1>Decoded</h1>
|
||||
var html_content = `<section style="margin: 100px auto; width:50%; height:50%; text-align:center;">
|
||||
<div style="width:100%; height:100%; text-align:center;">
|
||||
<h1 style="height:15%; width:90%; padding: 5%">Decoded</h1>
|
||||
<img src="upload/` + response["image"] + `" alt="Image Not Found">
|
||||
</div>
|
||||
<div>
|
||||
<h1>Secret Text:</h1>
|
||||
<p>` + response["payload"] + `</p>
|
||||
<div style="width:100%; height:100%; text-align:center;">
|
||||
<h1 style="height:15%; width:90%; padding: 5%">Secret Text:</h1>
|
||||
<p style="color: red">` + response["payload"] + `</p>
|
||||
</div>
|
||||
</section>`
|
||||
$("body").append(html_content)
|
||||
}
|
||||
else if(response.hasOwnProperty("wav")){
|
||||
var html_content = `<section>
|
||||
<h1>Decoded</h1>
|
||||
<audio controls>
|
||||
<source src="upload/` + response["wav"] + `" type="audio/wav">
|
||||
Your browser does not support the audio element.
|
||||
</audio>
|
||||
<div>
|
||||
<h1>Secret Text:</h1>
|
||||
<p>` + response["payload"] + `</p>
|
||||
</div>
|
||||
var html_content = `<section style="margin: 100px auto; width:50%; height:50%; text-align:center;">
|
||||
<h1 style="height:15%; width:90%; padding: 5%">Decoded</h1>
|
||||
<audio controls>
|
||||
<source src="upload/` + response["wav"] + `" type="audio/wav">
|
||||
Your browser does not support the audio element.
|
||||
</audio>
|
||||
<div>
|
||||
<h1 style="height:15%; width:90%; padding: 5%">Secret Text:</h1>
|
||||
<p>` + response["payload"] + `</p>
|
||||
</div>
|
||||
</section>`
|
||||
$("body").append(html_content)
|
||||
}
|
||||
|
@ -46,13 +47,13 @@
|
|||
fetch("upload/" + response["txt"])
|
||||
.then(res => res.text())
|
||||
.then(data => {
|
||||
var html_content = `<section>
|
||||
<div>
|
||||
<h1>Decoded</h1>
|
||||
<textarea>` + data + `</textarea>
|
||||
var html_content = `<section style="margin: 100px auto; width:50%; height:50%; text-align:center;">
|
||||
<div style="width:100%; height:100%; text-align:center;">
|
||||
<h1 style="height:15%; width:90%; padding: 5%">Decoded</h1>
|
||||
<textarea style="height:75%; width:90%; padding: 5%">` + data + `</textarea>
|
||||
</div>
|
||||
<div>
|
||||
<h1>Secret Text:</h1>
|
||||
<div style="width:100%; height:100%; text-align:center;">
|
||||
<h1 style="height:15%; width:90%; padding: 5%">Secret Text:</h1>
|
||||
<p>` + response["payload"] + `</p>
|
||||
</div>
|
||||
</section>`
|
||||
|
|
|
@ -8,6 +8,11 @@
|
|||
<title>Encode</title>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.4/jquery.min.js"></script>
|
||||
<style>
|
||||
*{
|
||||
padding: 0px;
|
||||
margin: 0px;
|
||||
}
|
||||
|
||||
.drop-zone {
|
||||
background-color: #f8f8f8;
|
||||
border: 2px dashed #cccccc;
|
||||
|
@ -65,6 +70,8 @@
|
|||
</head>
|
||||
|
||||
<body>
|
||||
<a style="text-decoration: none; color: white; display: inline-block; padding: 14px 16px; background-color: gray;" href="/">< Back</a>
|
||||
|
||||
<div class="form-container">
|
||||
<form action="/encoding" method="POST" enctype = "multipart/form-data">
|
||||
<div class="drop-zone" id="dropZone">
|
||||
|
|
|
@ -6,8 +6,20 @@
|
|||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||
<title>RESULT</title>
|
||||
<style>
|
||||
*{
|
||||
padding: 0px;
|
||||
margin: 0px;
|
||||
}
|
||||
|
||||
html, body{
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<a style="text-decoration: none; color: white; display: inline-block; padding: 14px 16px; background-color: gray;" href="/encode">< Back</a>
|
||||
</body>
|
||||
<script>
|
||||
|
||||
|
@ -16,13 +28,13 @@
|
|||
$.get('/get_session', function(response) {
|
||||
if(response.hasOwnProperty("image")){
|
||||
console.log(response)
|
||||
var html_content = `<section style="display: flex; justify-content: flex-start;">
|
||||
<div>
|
||||
<h1>Original</h1>
|
||||
var html_content = `<section style="margin: 100px auto; width:50%; height:50%; display: flex; justify-content: space-between;">
|
||||
<div style="border: 1px solid black; width:100%; height:100%; text-align:center;">
|
||||
<h1 style="height:15%; width:90%; padding: 5%">Original</h1>
|
||||
<img src="upload/` + response["image"] + `" alt="Image Not Found">
|
||||
</div>
|
||||
<div>
|
||||
<h1>Encoded</h1>
|
||||
<div style="border: 1px solid black; width:100%; height:100%; text-align:center;">
|
||||
<h1 style="height:15%; width:90%; padding: 5%">Encoded</h1>
|
||||
<img src="upload/` + response["image2"] + `" alt="Image Not Found">
|
||||
</div>
|
||||
|
||||
|
@ -30,16 +42,16 @@
|
|||
$("body").append(html_content)
|
||||
}
|
||||
else if(response.hasOwnProperty("wav")){
|
||||
var html_content = `<section style="display: flex; justify-content: flex-start;">
|
||||
<div>
|
||||
<h1>Original</h1>
|
||||
var html_content = `<section style="margin: 100px auto; width:50%; height:50%; display: flex; justify-content: space-between;">
|
||||
<div style="border: 1px solid black; width:100%; height:100%; text-align:center;">
|
||||
<h1 style="height:15%; width:90%; padding: 5%">Original</h1>
|
||||
<audio controls>
|
||||
<source src="upload/` + response["wav"] + `" type="audio/wav">
|
||||
Your browser does not support the audio element.
|
||||
</audio>
|
||||
</div>
|
||||
<div>
|
||||
<h1>Encoded</h1>
|
||||
<div style="border: 1px solid black; width:100%; height:100%; text-align:center;">
|
||||
<h1 style="height:15%; width:90%; padding: 5%">Encoded</h1>
|
||||
<audio controls>
|
||||
<source src="upload/` + response["wav2"] + `" type="audio/wav">
|
||||
Your browser does not support the audio element.
|
||||
|
@ -56,14 +68,14 @@
|
|||
fetch("upload/" + response["txt2"])
|
||||
.then(res2 => res2.text())
|
||||
.then(data2 => {
|
||||
var html_content = `<section style="display: flex; justify-content: flex-start;">
|
||||
<div>
|
||||
<h1>Original</h1>
|
||||
<textarea>` + data + `</textarea>
|
||||
var html_content = `<section style="margin: 100px auto; width:50%; height:50%; display: flex; justify-content: space-between;">
|
||||
<div style="border: 1px solid black; width:100%; height:100%; text-align:center;">
|
||||
<h1 style="height:15%; width:90%; padding: 5%">Original</h1>
|
||||
<textarea style="height:77%; width:100%">` + data + `</textarea>
|
||||
</div>
|
||||
<div>
|
||||
<h1>Encoded</h1>
|
||||
<textarea>` + data2 + `</textarea>
|
||||
<div style="border: 1px solid black; width:100%; height:100%; text-align:center;">
|
||||
<h1 style="height:15%; width:90%; padding: 5%">Encoded</h1>
|
||||
<textarea style="height:77%; width:100%">` + data2 + `</textarea>
|
||||
</div>
|
||||
|
||||
</section>`
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<title>File Unsupported</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
background-color: #f2f2f2;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 100vh;
|
||||
}
|
||||
|
||||
.container {
|
||||
text-align: center;
|
||||
background-color: #fff;
|
||||
padding: 30px;
|
||||
border-radius: 5px;
|
||||
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
h1 {
|
||||
color: #333;
|
||||
font-size: 28px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
p {
|
||||
color: #777;
|
||||
font-size: 18px;
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
|
||||
.icon {
|
||||
width: 120px;
|
||||
height: 120px;
|
||||
border-radius: 50%;
|
||||
background-color: red;
|
||||
margin: 0px auto;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 60px;
|
||||
color: white;
|
||||
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.4);
|
||||
}
|
||||
|
||||
.icon::before {
|
||||
content: "X";
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>File Unsupported</h1>
|
||||
<p>We're sorry, but the file format you uploaded is not supported.</p>
|
||||
<div class="icon"></div>
|
||||
<a style="text-decoration: none; color: black; display: inline-block; margin: 20px 0px 0px; padding: 14px 16px;" href="#" onclick="history.back()">< Back</a>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
Loading…
Reference in New Issue