CODE IN C++
#include<iostream>
using namespace std;
int GCD(int a, int b, int *x, int *y)
{
if (a == 0)
{
*x = 0, *y = 1;
return b;
}
int x1, y1;
int gcd = GCD(b%a, a, &x1, &y1);
*x = y1 - (b/a) * x1;
*y = x1;
return gcd;
}
void modInverse(int a, int m)
{
int x, y;
int g = GCD(a, m, &x, &y);
if (g != 1)
cout << "Inverse does nOt exist!!";
else
{
int res = (x%m + m) % m;
cout << "Modular inverse is " << res;
}
}
// Driver Program
int main()
{
int a, n;
cout << "Enter the value of n: ";
cin >> n;
cout << "Enter the value of a (>= 0): ";
cin >> a;
modInverse(a, n);
return 0;
}
Project 2: The Inverse Modulo n [MOD] Textbook Section: 7.37 Directions: The user will input the...
Write code for RSA encryption package rsa; import java.util.ArrayList; import java.util.Random; import java.util.Scanner; public class RSA { private BigInteger phi; private BigInteger e; private BigInteger d; private BigInteger num; public static void main(String[] args) { Scanner keyboard = new Scanner(System.in); System.out.println("Enter the message you would like to encode, using any ASCII characters: "); String input = keyboard.nextLine(); int[] ASCIIvalues = new int[input.length()]; for (int i = 0; i < input.length(); i++) { ASCIIvalues[i] = input.charAt(i); } String ASCIInumbers...