Updated to 8 bit checkbox

This commit is contained in:
cleontay 2023-05-30 18:47:57 +08:00
parent 5ef0893381
commit 5d3133a3a9
3 changed files with 27 additions and 9 deletions

View File

@ -4,10 +4,7 @@ import cv2
import os
import sys
script_directory = os.path.dirname(os.path.abspath(sys.argv[0]))
current_directory = os.getcwd()
WORKING_PATH = os.path.relpath(script_directory, current_directory)
WORKING_PATH = os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])), "upload") + os.sep
app = Flask(__name__, template_folder='views')
app.secret_key = 'b3a5e8d11fb3d8d3647b6cf2e51ad768'
@ -30,7 +27,8 @@ def encode():
@app.route("/encoding", methods=['POST'])
def encoding():
file = request.files['origin']
b2c = [int(request.form['b2c'])]
b2c = [int(x) for x in request.form.getlist("b2c")]
# b2c = [int(request.form['b2c'])]
payload = request.form['payload']
if file.filename != "":
@ -56,7 +54,9 @@ def decode():
@app.route("/decoding", methods=['POST'])
def decoding():
file = request.files['encoded_file']
b2c = [int(request.form['b2c'])]
b2c = [int(x) for x in request.form.getlist("b2c")]
# b2c = [int(request.form['b2c'])]
print(b2c)
if file.filename != "":
file.save(WORKING_PATH + file.filename)
payload = img_steg.img_steg(WORKING_PATH + file.filename, b2c).decode()

View File

@ -66,8 +66,16 @@
<div class="upload-text">Drag and drop an image here or click to browse</div>
<input type="file" name="encoded_file" id="fileInput">
</div>
<div style="width: 100%; text-align: center; padding: 10px 0px">
<input type="number" name="b2c" placeholder="Bits" min="0" max="8">
<label for="b2c">Bits to Change:</label>
<div>
<input type="checkbox" name="b2c" value="8" placeholder="8">
<input type="checkbox" name="b2c" value="7" placeholder="7">
<input type="checkbox" name="b2c" value="6" placeholder="6">
<input type="checkbox" name="b2c" value="5" placeholder="5">
<input type="checkbox" name="b2c" value="4" placeholder="4">
<input type="checkbox" name="b2c" value="3" placeholder="3">
<input type="checkbox" name="b2c" value="2" placeholder="2">
<input type="checkbox" name="b2c" value="1" placeholder="1">
</div>
<div style="width: 100%; text-align: center; padding: 10px 0px">
<input type="submit" value="Decode">

View File

@ -69,7 +69,17 @@
<input type="file" name="origin" id="fileInput">
</div>
<div style="width: 100%; text-align: center; padding: 10px 0px">
<input type="number" name="b2c" placeholder="Bits" min="0" max="8">
<label for="b2c">Bits to Change:</label>
<div>
<input type="checkbox" name="b2c" value="8" placeholder="8">
<input type="checkbox" name="b2c" value="7" placeholder="7">
<input type="checkbox" name="b2c" value="6" placeholder="6">
<input type="checkbox" name="b2c" value="5" placeholder="5">
<input type="checkbox" name="b2c" value="4" placeholder="4">
<input type="checkbox" name="b2c" value="3" placeholder="3">
<input type="checkbox" name="b2c" value="2" placeholder="2">
<input type="checkbox" name="b2c" value="1" placeholder="1">
</div>
<input type="text" name="payload" placeholder="Secret Code">
<input type="submit" value="Encode">
</div>