def encrypt_message(plaintext, publickey):
    # encrypt the message
    # privateKey is a elgamal object
    # return elgamal.encrypt(publicKey, plaintext)
    cypher_int = encrypt(publickey, plaintext)
    cypher_compressed = '|'.join(key_compress(int(n)) for n in cypher_int.strip(' ').split(' '))
    return cypher_compressed
 def test_compress_expand(self):
     # round trip compress, decompress public key
     n = random.getrandbits(300)
     short = key_compress(n)
     backagain = key_expand(short)
     # nlen = len(str(n))
     # print (nlen, len(short), float(len(short))/nlen)
     assert n == backagain, (n, short)