File tree Expand file tree Collapse file tree 3 files changed +13
-5
lines changed
python-bitwise-operators/stegano Expand file tree Collapse file tree 3 files changed +13
-5
lines changed Original file line number Diff line number Diff line change 55
66from .bitmap import Bitmap
77from .cli import CommandLineArguments , parse_args
8- from .decoder import decode
9- from .encoder import encode
8+ from .decoder import decode , DecodingError
9+ from .encoder import encode , EncodingError
1010from .eraser import erase
1111
1212
@@ -24,5 +24,5 @@ def main(args: CommandLineArguments) -> None:
2424if __name__ == "__main__" :
2525 try :
2626 main (parse_args ())
27- except Exception as ex : # pylint: disable=W0703
27+ except ( EncodingError , DecodingError ) as ex :
2828 print (ex )
Original file line number Diff line number Diff line change 99from .bitmap import Bitmap
1010
1111
12+ class DecodingError (Exception ):
13+ pass
14+
15+
1216def decode (bitmap : Bitmap ) -> None :
1317 """Extract a secret file from the bitmap."""
1418
1519 if bitmap .reserved_field <= 0 :
16- raise ValueError ("Secret file not found in the bitmap" )
20+ raise DecodingError ("Secret file not found in the bitmap" )
1721
1822 iterator = secret_bytes (bitmap )
1923
Original file line number Diff line number Diff line change 88from .bitmap import Bitmap
99
1010
11+ class EncodingError (Exception ):
12+ pass
13+
14+
1115class SecretFile :
1216 """Convenience class for serializing secret data."""
1317
@@ -35,7 +39,7 @@ def encode(bitmap: Bitmap, path: pathlib.Path) -> None:
3539 file = SecretFile (path )
3640
3741 if file .num_secret_bytes > bitmap .max_bytes :
38- raise ValueError ("Not enough pixels to embed a secret file" )
42+ raise EncodingError ("Not enough pixels to embed a secret file" )
3943
4044 bitmap .reserved_field = file .size_bytes
4145 for secret_byte , eight_bytes in zip (file .secret_bytes , bitmap .byte_slices ):
You can’t perform that action at this time.
0 commit comments