\\ Assume given the RSA triple (publick,secret,modulus) this \\ implements encryption and decryption of messages. \\ One should probably use the bit-picking \\ operators in pari to give left-right exponentiation expon(base,exponent,modulus)= { local(u,p); u=1;p=block; while(exponent>0, if( exponent%2 != 0, u = (u*p)%modulus; ); exponent=exponent\2; p=(p*p)%modulus; ) return(u); } \\ small message blocks should probably be \\ given some random additional noise! encrypt(key,modulus,message)= { local(channel); channel=0; block=message%(modulus-1); while(block != 0, channel=channel*(modulus-1)+expon(block,key,modulus); message=message \ (modulus-1); block=message%(modulus-1); ); } decrypt(key,modulus,channel)= { encrypt(key,modulus,channel); // Entirely symmetric key !!! }