I am developing a project for sending an encrypted data over a LAN using RSA. i should have two large prime numbers say P and Q and then say that n = P*Q. then say that a value phi =(P-1)*(Q-1)
and find a value e such that 1<e<phi and the gcd(e,phi)=1.
the problem is i should have a value d such that
e*d mod phi = 1 . i always get an error saying that arthimitic operation flows.
i have done this
Dim p,q As Long
Dim e1,d As Long
Dim n,phi As Long
Dim x, y As Long
Dim i As Long
Randomize()
x = 10000 + Rnd() * 10000
While (Not isprime(x))
x = 10000 + Rnd() * 10000
End While
p = x
Randomize()
y = 10000 + Rnd() * 10000
While (Not isprime(y))
y = 10000 + Rnd() * 10000
End While
q = y
n = p * q
phi = (p - 1) * (q - 1)
Dim e11 As Long
Randomize()
e11 = 1 + Rnd() * phi
While (gcd(e11, phi) <> 1)
e11 = e11 + 1
End While
e1 = e11
Dim d1 As Long
Randomize()
d1 = 1 + Rnd() * phi
While (e1 * d1 Mod phi <> 1)

'here the problem occurs
d1 = d1 + 1
End While
d = d1