def encipher_elgamal(i, key, seed=None):
 (p, r, e) = key
 if ((i < 0) or (i >= p)):
  raise ValueError(('Message (%s) should be in range(%s)' % (i, p)))
 randrange = _randrange(seed)
 a = randrange(2, p)
 return (pow(r, a, p), ((i * pow(e, a, p)) % p))

def encipher_elgamal ( i , key , seed = None ) : ( p , r , e ) = key if ( ( i < 0 ) or ( i >= p ) ) : raise ValueError ( ( 'Message (%s) should be in range(%s)' % ( i , p ) ) ) randrange = _randrange ( seed ) a = randrange ( 2 , p ) return ( pow ( r , a , p ) , ( ( i * pow ( e , a , p ) ) % p ) )
encrypt message with public key i is a plaintext message expressed as an integer .