<s> from Crypto . Cipher import AES <EOL> from django import forms <EOL> from django . forms import ValidationError <EOL> from . utils import get_decode_key <EOL> class DecodeForm ( forms . Form ) : <EOL> optional_decode_key = forms . CharField ( required = False ) <EOL> message = forms . CharField ( widget = forms . Textarea , required = True ) <EOL> def clean_optional_decode_key ( self ) : <EOL> optional_decode_key = self . cleaned_data [ '<STR_LIT>' ] . strip ( ) <EOL> if optional_decode_key : <EOL> if len ( optional_decode_key ) != <NUM_LIT:64> : <EOL> raise ValidationError ( '<STR_LIT>' ) <EOL> try : <EOL> decode_key = optional_decode_key . decode ( '<STR_LIT>' ) <EOL> except TypeError as e : <EOL> raise ValidationError ( '<STR_LIT>' % e . msg ) <EOL> return decode_key <EOL> def clean_message ( self ) : <EOL> message = self . cleaned_data [ '<STR_LIT:message>' ] <EOL> try : <EOL> message = message . decode ( '<STR_LIT>' ) <EOL> except TypeError as e : <EOL> raise ValidationError ( '<STR_LIT>' % e . msg ) <EOL> if len ( message ) % <NUM_LIT:16> : <EOL> raise ValidationError ( '<STR_LIT>' ) <EOL> if len ( message ) <= <NUM_LIT:16> : <EOL> raise ValidationError ( '<STR_LIT>' ) <EOL> return message </s>
