#NEWLINE# def _decrypt( self , message ) : #NEWLINE# #INDENT# if ( not self . alive ( ) ) : #NEWLINE# #INDENT# raise Exception ( 'Subscription is not alive' ) #NEWLINE# #UNINDENT# from pubnub import AES #NEWLINE# delivery_mode = self . _subscription [ 'deliveryMode' ] #NEWLINE# is_encrypted = ( ( 'encryption' in delivery_mode ) and ( 'encryptionKey' in delivery_mode ) ) #NEWLINE# if is_encrypted : #NEWLINE# #INDENT# key = base64 . b64decode ( self . _subscription [ 'deliveryMode' ] [ 'encryptionKey' ] ) #NEWLINE# data = base64 . b64decode ( delivery_mode ) #NEWLINE# obj2 = AES . new ( key ) #NEWLINE# decrypted = str ( obj2 . decrypt ( data ) ) . replace ( '\x05' , '' ) #NEWLINE# message = json . loads ( decrypted ) #NEWLINE# #UNINDENT# return message