def RSAencrypt(m,e,n): ndigits=len(str(n)) chunkSize=ndigits-1 chunks=toChunks(m,chunkSize) encList=[] for messChunk in chunks: c=modexp(int(messChunk),e,n) encList.append(c) return encList
def RSAdecrypt(clist,d,n): rList=[] for c in clist: m=modexp(c,d,n) rList.append(m) return rList