def test_EncryptDecryptMessage(self):
     """
     uses message and key compression
     """
     plaintext = 'Hello Twitter world in 140 characters.'
     pub = assemble_publickey(h1_keys['PublicKeyTwitter'])
     encrypted = encrypt_message(plaintext, pub)
     # print(encrypted)
     prk = h1_keys['PrivateKey']
     priv = assemble_privatekey((prk['p'], prk['g'], prk['x'], prk['iNumBits']))
     decrypted = decrypt_message(priv, encrypted, )
     # print(decrypted)
     assert plaintext == decrypted
 def test_SendEncryptedStatusupdate(self):
     if userkeys:
         plaintext = 'Hello Twitter world'
         # keys
         pub = assemble_publickey(h1_keys['PublicKeyTwitter'])
         prk = h1_keys['PrivateKey']
         priv = assemble_privatekey((prk['p'], prk['g'], prk['x'], prk['iNumBits']))
         encrypted = encrypt_message(plaintext, pub)
         # Send
         twitter = Twython(consumer_key, consumer_sec, access_tok, access_token_sec)
         print(encrypted)
         send_status_update(twitter, encrypted)
         # read
         user_timeline = twitter.get_user_timeline(screen_name='HeteroT1', count=1, exclude_replies=True)
         lastmessage = user_timeline[0]['text']
         decrypted = decrypt_message(priv, lastmessage)
         print(decrypted)
         assert plaintext == decrypted