Weblog of an Aspiring Computer Scientist
Random header image... Refresh for more!

Chinese remainder theorem

Have a look at this. I found this question in my neighbour’s CS book. He is a CS student and his college’s introductory CS course is taught in C (Sadly I don’t know C :( )

import nzmath.gcd

def crt(xl,ml):

    k = len(xl)

    m = ml[0]

    x = xl[0]

    for i in range(1,k):

        u,v,d = gcd.extgcd(m,ml[i])

        if d > 1:

            raise Error

            x = u*m*xl[i] + v*l[i]*x

            m = m*ml[i]

            x = x%m

    return x

There seemingly is an RSA based on the CRT but I don’t know about that. This question really got me to think.

3 comments

1 realleaws { 04.21.08 at 11:22 pm }

Thank you very much for a good site

2 Avradip { 05.06.08 at 12:47 am }

Dude u made my day…. i was searching for some CRT code online… here u are (too lazy to write myself ;) )…
By the way hope u know by how CRT is used in RSA… that’s really a classic example which shows how important is CRT.

3 Shriphani { 05.06.08 at 3:33 am }

Glad to be of help. I might do a few posts on cryptography :)

Leave a Comment