62 lines
2.3 KiB
Diff
62 lines
2.3 KiB
Diff
--- 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:
|