Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Convert this C++ code to Java code please attach samples run of the code #include #include #include #include #include #include main() { long int p,g,Sa=0,Sb=0,Ta,Tb,Skey1,Skey2,Skey;

Convert this C++ code to Java code

please attach samples run of the code

#include

#include

#include

#include

#include

#include

main()

{

long int p,g,Sa=0,Sb=0,Ta,Tb,Skey1,Skey2,Skey;

clrscr();

cout<<"Enter a Value for p :";

cin>>p;

cout<<" Enter a Value for g :";

cin>>g;

//======== Generate Sa and Sb Values Randomly between 0 and 20

Sa=random(20);

Sb=random(20);

//======== Calculate Ta and Tb Values

Ta=(pow(g,Sa));

Ta=Ta%p;

Tb=(pow(g,Sb));

Tb=Tb%p;

//======== Calculate Secret Key Values

Skey1=(pow(Tb,Sa));

Skey1=Skey1%p;

Skey2=(pow(Ta,Sb));

Skey2=Skey2%p;

if(Skey1==Skey2)

Skey=Skey1;

//========= Print Secret Key Value

cout<<" The random Number of SA is :"<

cout<<" The random Number of SA is :"<

cout<<" The Value of Secret Key is :"<

getch();

return 0;

}

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

Conceptual Database Design An Entity Relationship Approach

Authors: Carol Batini, Stefano Ceri, Shamkant B. Navathe

1st Edition

0805302441, 978-0805302448

More Books

Students also viewed these Databases questions