Fixing container disaster.
This commit is contained in:
61
patches/01_stegasoo_init_decode.patch
Normal file
61
patches/01_stegasoo_init_decode.patch
Normal file
@@ -0,0 +1,61 @@
|
||||
--- a/src/stegasoo/__init__.py
|
||||
+++ b/src/stegasoo/__init__.py
|
||||
@@ -189,6 +189,7 @@ def decode(
|
||||
pin: str = "",
|
||||
rsa_key_data: Optional[bytes] = None,
|
||||
rsa_password: Optional[str] = None,
|
||||
+ date_str: Optional[str] = None,
|
||||
) -> DecodeResult:
|
||||
"""
|
||||
Decode a secret message or file from a stego image.
|
||||
@@ -201,6 +202,7 @@ def decode(
|
||||
day_phrase: Passphrase for the day message was encoded
|
||||
pin: Static PIN (if used during encoding)
|
||||
rsa_key_data: RSA private key PEM bytes (if used during encoding)
|
||||
rsa_password: Password for RSA key if encrypted
|
||||
+ date_str: Date the message was encoded (YYYY-MM-DD). If not provided,
|
||||
+ tries today's date. Get this from the stego filename.
|
||||
|
||||
Returns:
|
||||
@@ -221,8 +223,12 @@ def decode(
|
||||
if rsa_key_data:
|
||||
require_valid_rsa_key(rsa_key_data, rsa_password)
|
||||
|
||||
- # Try to extract with today's date first
|
||||
- date_str = date.today().isoformat()
|
||||
+ # Use provided date or fall back to today
|
||||
+ if date_str is None:
|
||||
+ date_str = date.today().isoformat()
|
||||
+ debug.print(f"No date provided, using today: {date_str}")
|
||||
+ else:
|
||||
+ debug.print(f"Using provided date: {date_str}")
|
||||
+
|
||||
pixel_key = derive_pixel_key(
|
||||
reference_photo, day_phrase, date_str, pin, rsa_key_data
|
||||
)
|
||||
@@ -270,6 +276,7 @@ def decode_text(
|
||||
pin: str = "",
|
||||
rsa_key_data: Optional[bytes] = None,
|
||||
rsa_password: Optional[str] = None,
|
||||
+ date_str: Optional[str] = None,
|
||||
) -> str:
|
||||
"""
|
||||
Decode a text message from a stego image.
|
||||
@@ -283,12 +290,13 @@ def decode_text(
|
||||
day_phrase: Passphrase for the day message was encoded
|
||||
pin: Static PIN (if used during encoding)
|
||||
rsa_key_data: RSA private key PEM bytes (if used during encoding)
|
||||
rsa_password: Password for RSA key if encrypted
|
||||
+ date_str: Date the message was encoded (YYYY-MM-DD)
|
||||
|
||||
Returns:
|
||||
Decrypted message string
|
||||
|
||||
Raises:
|
||||
DecryptionError: If content is a binary file, not text
|
||||
"""
|
||||
debug.print("decode_text called")
|
||||
- result = decode(stego_image, reference_photo, day_phrase, pin, rsa_key_data, rsa_password)
|
||||
+ result = decode(stego_image, reference_photo, day_phrase, pin, rsa_key_data, rsa_password, date_str)
|
||||
|
||||
if result.is_file:
|
||||
80
patches/02_decode_html_date_field.patch
Normal file
80
patches/02_decode_html_date_field.patch
Normal file
@@ -0,0 +1,80 @@
|
||||
--- a/frontends/web/templates/decode.html
|
||||
+++ b/frontends/web/templates/decode.html
|
||||
@@ -35,6 +35,9 @@
|
||||
{% else %}
|
||||
<!-- Decode Form -->
|
||||
<form method="POST" enctype="multipart/form-data" id="decodeForm">
|
||||
+ <!-- Hidden field for encoding date (detected from filename) -->
|
||||
+ <input type="hidden" name="stego_date" id="stegoDate" value="">
|
||||
+
|
||||
<div class="row">
|
||||
<div class="col-md-6 mb-3">
|
||||
<label class="form-label">
|
||||
@@ -171,10 +174,20 @@ document.getElementById('togglePin')?.addEventListener('click', function() {
|
||||
// Detect day from filename
|
||||
function detectDayFromFilename(filename) {
|
||||
const dateMatch = filename.match(/_(\d{4})[-]?(\d{2})[-]?(\d{2})/);
|
||||
-
|
||||
if (dateMatch) {
|
||||
const [, year, month, day] = dateMatch;
|
||||
const date = new Date(year, month - 1, day);
|
||||
+ return {
|
||||
+ dayName: dayNames[date.getDay()],
|
||||
+ dateStr: `${year}-${month}-${day}`
|
||||
+ };
|
||||
+ }
|
||||
+ return null;
|
||||
+}
|
||||
+
|
||||
+// Legacy function for day name only
|
||||
+function detectDayFromFilenameOld(filename) {
|
||||
+ const result = detectDayFromFilename(filename);
|
||||
+ if (result) {
|
||||
- return dayNames[date.getDay()];
|
||||
+ return result.dayName;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -182,8 +195,14 @@ function detectDayFromFilename(filename) {
|
||||
// Update day phrase label
|
||||
-function updateDayLabel(dayName) {
|
||||
+function updateDayLabel(dayName, dateStr) {
|
||||
const label = document.getElementById('dayPhraseLabel');
|
||||
if (label && dayName) {
|
||||
label.innerHTML = `<i class="bi bi-chat-quote me-1"></i>Provide <span class="day-of-week-highlight">${dayName}</span>'s Phrase`;
|
||||
}
|
||||
+
|
||||
+ // Set the hidden date field
|
||||
+ const dateField = document.getElementById('stegoDate');
|
||||
+ if (dateField && dateStr) {
|
||||
+ dateField.value = dateStr;
|
||||
+ console.log('Set stego date to:', dateStr);
|
||||
+ }
|
||||
}
|
||||
|
||||
@@ -232,8 +251,10 @@ document.querySelectorAll('.drop-zone').forEach(zone => {
|
||||
showPreview(file);
|
||||
|
||||
if (isStegoZone) {
|
||||
- const dayName = detectDayFromFilename(file.name);
|
||||
- updateDayLabel(dayName);
|
||||
+ const detected = detectDayFromFilename(file.name);
|
||||
+ if (detected) {
|
||||
+ updateDayLabel(detected.dayName, detected.dateStr);
|
||||
+ }
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -244,8 +265,10 @@ document.querySelectorAll('.drop-zone').forEach(zone => {
|
||||
showPreview(file);
|
||||
|
||||
if (isStegoZone) {
|
||||
- const dayName = detectDayFromFilename(file.name);
|
||||
- updateDayLabel(dayName);
|
||||
+ const detected = detectDayFromFilename(file.name);
|
||||
+ if (detected) {
|
||||
+ updateDayLabel(detected.dayName, detected.dateStr);
|
||||
+ }
|
||||
}
|
||||
}
|
||||
});
|
||||
22
patches/03_app_py_decode_date.patch
Normal file
22
patches/03_app_py_decode_date.patch
Normal file
@@ -0,0 +1,22 @@
|
||||
--- a/frontends/web/app.py
|
||||
+++ b/frontends/web/app.py
|
||||
@@ -324,6 +324,9 @@ def decode_page():
|
||||
day_phrase = request.form.get('day_phrase', '')
|
||||
pin = request.form.get('pin', '').strip()
|
||||
rsa_password = request.form.get('rsa_password', '')
|
||||
+
|
||||
+ # Get encoding date from form (detected from filename in JS)
|
||||
+ stego_date = request.form.get('stego_date', '').strip()
|
||||
|
||||
if not day_phrase:
|
||||
flash('Day phrase is required', 'error')
|
||||
@@ -373,7 +376,8 @@ def decode_page():
|
||||
day_phrase=day_phrase,
|
||||
pin=pin,
|
||||
rsa_key_data=rsa_key_data,
|
||||
- rsa_password=key_password
|
||||
+ rsa_password=key_password,
|
||||
+ date_str=stego_date if stego_date else None
|
||||
)
|
||||
|
||||
if decode_result.is_file:
|
||||
Reference in New Issue
Block a user