Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in Visual Basic, How could i produce a private key (e,d) in RSA ( e * d congruent to 1 mod n) i already have

in Visual Basic,

How could i produce a private key (e,d) in RSA ( e * d congruent to 1 mod n)

i already have the public key, but how could i find d and code it

ie) outputs to a textbox

in my code

e1 * d congruent to 1 mod n

image text in transcribedimage text in transcribed

Private Sub Button1_Click( sender As Object, e As EventArgs) Handles Button1.click Dim n As Long Dim phin As Integer Dim e1 As Integer Dim prime Dim prime2 As Integer = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97} As Integer - {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97}' Dim p As Integer = prime (New Random().Next(0, prime. Length - 1))' picks between the Primes listed above Dim q As Integer = p Dim max As Integer Dim min As Integer Do Until p q 'since we need two distinct primes, this loop was needed q = prime(New Random().Next(@, prime. Length - 1)) Loop n = p * a TextBox1.Text = n phin = Phin) e1 = Phi(n) - 1 TextBox2.Text = el End Sub Function Phi(ByVal z As Long) Dim count, i As Long For i = 1 To z - 1 If gcd(i, z) = 1 Then count += 1 End If Next Return count End Function Function gcd(ByVal n As Long, ByVal m As Long) As Long Dim r, p, q As Integer p = Math.Max(n, m) q = Math.min(n, m) r = p Mod a Do While r > 0 P = a 9 = r r = p Moda Loop Return a End Function Private Sub Button1_Click( sender As Object, e As EventArgs) Handles Button1.click Dim n As Long Dim phin As Integer Dim e1 As Integer Dim prime Dim prime2 As Integer = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97} As Integer - {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97}' Dim p As Integer = prime (New Random().Next(0, prime. Length - 1))' picks between the Primes listed above Dim q As Integer = p Dim max As Integer Dim min As Integer Do Until p q 'since we need two distinct primes, this loop was needed q = prime(New Random().Next(@, prime. Length - 1)) Loop n = p * a TextBox1.Text = n phin = Phin) e1 = Phi(n) - 1 TextBox2.Text = el End Sub Function Phi(ByVal z As Long) Dim count, i As Long For i = 1 To z - 1 If gcd(i, z) = 1 Then count += 1 End If Next Return count End Function Function gcd(ByVal n As Long, ByVal m As Long) As Long Dim r, p, q As Integer p = Math.Max(n, m) q = Math.min(n, m) r = p Mod a Do While r > 0 P = a 9 = r r = p Moda Loop Return a End Function

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Real Time Database And Information Systems Research Advances

Authors: Azer Bestavros ,Victor Fay-Wolfe

1st Edition

1461377803, 978-1461377801

More Books

Students also viewed these Databases questions