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