Decrypting RSA cipher text when given N e and d

7.4k Views Asked by At

The cipher text is wqlizYbFyjOp95Bt.ViLWHhEBx2 N=7231645985673347207280720222548553948759779729581 e=3 d=4821097323782215625692549251331855329314609896043 where d is the private key How do i solve this?

2

There are 2 best solutions below

5
On BEST ANSWER

Your ciphertext was wqlizYbFyjOp95Bt.ViLWHhEBx2 using the 64-base alphabet (from the comments; it should have been part of the question!) abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-

You can write functions to convert strings to numbers and numbers back to strings, e.g. using Python:

def toDec(c):
    alph='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-'
    value=0
    b=1 #value of current position
    for w in reversed(list(c)):
            value += b*alph.index(w)
            b *= 64
    return value

and

def toBase(n):
    alph='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-'
    s=''
    while n:
            s =  str(alph[n % 64]) + s
            n -= n%64
            n/=64
    return s

So your ciphertext string represents the number c=2032648950572077788772410497891338100431128212982 which is indeed $< N$ where N= 7231645985673347207280720222548553948759779729581

Decryption in RSA is exponentation by $d$ modulo $N$: $m=c^d \bmod{N}$ and this gives the number $m=49409962907892021177240969231692222477$.

Converting back to the base again to get a textual representation we get

toBase(m) = Llanbedr-Pont-Steffan

which seems to be the Welsh name for Lampeter

1
On

If you want to encrypt some text, then you take the message to a number $n < N$. the cypher text is then $$ c = n^e \mod N $$ To recover the plaintext you calculate $$ n = c^d \mod N $$ and then take this back to the plaintext