Check if the generator is implemented in Stegano.

This commit is contained in:
Cédric Bonhomme 2016-05-22 00:13:29 +02:00
parent d850bbd8a0
commit a0f6f24d7c
No known key found for this signature in database
GPG key ID: A1CB94DE57B7A70D
3 changed files with 13 additions and 5 deletions

View file

@ -66,9 +66,13 @@ def hide(input_image_file, message, generator_function, auto_convert_rgb=False):
npixels = width * height
len_message_bits = len(message_bits)
if len_message_bits > npixels * 3:
raise Exception("""The message you want to hide is too long (%s > %s).""" % (len_message_bits, npixels * 3))
raise Exception("The message you want to hide is too long: {}".\
format(message_length))
generator = getattr(generators, generator_function)()
try:
generator = getattr(generators, generator_function)()
except AttributeError as e:
raise e
while index + 3 <= len_message_bits :
generated_number = next(generator)