Write a program that can encrypt and decrypt using the El-GAMALCipher Please show in Java with message = 100.
/* ElGamalEncryptDecrypt.java */
package dateoperation;
import java.math.*;
import java.util.*;
import java.security.*;
import java.io.*;
public class ElGamalEncryptDecrypt
{
public static void main(String[] args) throws
IOException
{
BigInteger secretKey,p,
b, c;
Random random = new
SecureRandom();
secretKey = new
BigInteger("12345678901234567890");
///getting public
key
System.out.println("Your
secretKey = " + secretKey);
p =
BigInteger.probablePrime(64, random);
b = new
BigInteger("3");
c = b.modPow(secretKey,
p);
System.out.println("p =
" + p);
System.out.println("b =
" + b);
System.out.println("c =
" + c);
//
// Encryption
// 100 as plain
text
String plaintext
="100";
BigInteger X = new
BigInteger(plaintext);
BigInteger r = new
BigInteger(64, random);
BigInteger
Encryptedmessage = X.multiply(c.modPow(r, p)).mod(p);
BigInteger brmodp =
b.modPow(r, p);
System.out.println("Plaintext = " + X);
System.out.println("r =
" + r);
System.out.println("Encrypted Message = " +
Encryptedmessage);
System.out.println("b^r
mod p = " + brmodp);
//
// Decryption
//
BigInteger crmodp =
brmodp.modPow(secretKey, p);
BigInteger d =
crmodp.modInverse(p);
BigInteger
DecryptedMessage = d.multiply(Encryptedmessage).mod(p);
System.out.println("\n\nc^r mod p = " + crmodp);
System.out.println("d =
" + d);
System.out.println("Decrypted Message: " + DecryptedMessage);
}
}
/*
output
run:
Your secretKey = 12345678901234567890
p = 15529472551224172823
b = 3
c = 15214339181978182378
Plaintext = 100
r = 1766218395270747804
Encrypted Message = 8737472744694909418
b^r mod p = 9030210705495725744
c^r mod p = 5367395394863167854
d = 13554491082901739413
Decrypted Message: 100
BUILD SUCCESSFUL (total time: 0 seconds)
*/
Write a program that can encrypt and decrypt using the El-GAMALCipher Please show in Java with...
Write a java program to encrypt and decrypt a message. The user should be able to choose between a Caesar cipher or a Vigenere cipher for their message. Use JOptionPane for user input.
Write a short Java program that uses private key (symmetric) encryption method to encrypt a short string. Approximate algorithm: Enter a text string Use Java to generate a key and encrypt the string Use Java (and the key) to decrypt the string Compare original and decrypted string to make sure it is the same Note: Please make it as simple as possible
C Programming - RSA Encryption I've tried to write a program that can encrypt and decrypt strings using RSA and want to be able to integrate it into a header file which contains codes for compression, linked list etc.. However, the use of global variables and fixed size of encryption is making it hard to do so Can someone please help me modify the following the code? I want to be able to just pass it in a string to...
C Programming - RSA Encryption I've tried to write a program that can encrypt and decrypt strings using RSA and want to be able to integrate it into a header file which contains codes for compression, linked list etc.. However, the use of global variables and fixed size of encryption is making it hard to do so Can someone please help me modify the following the code? I want to be able to just pass it in a string to...
C PROGRAMMING Implement a function (using only #include library) that can encrypt/decrypt with a substitution cipher. cipher_sub (a, b, c, d) a is the string that has the data that will be encrypted or decrypted b is the string that has the result of the encrypt/decrypt c is the code string used for our substitution cipher (27 entries plus '\0' character) d is an integer that will pass two constants defined as ENC (encrypt) or DEC (decrypt) --> The function...
Using RSA cipher, public key e=3, private key d=7 Encrypt the following message “Hello there” Decrypt the previous message
C Programming - RSA encryption Hi there, I'm struggling with writing a C program to encrypt and decrypt a string using the RSA algorithm (C90 language only). It can contain ONLY the following libraries: stdio, stdlib, math and string. I want to use the following function prototypes to try and implement things: /*Check whether a given number is prime or not*/ int checkPrime(int n) /*to find gcd*/ int gcd(int a, int h) void Encrypt(); void Decrypt(); int getPublicKeys(); int getPrivateKeys();...
Java program please
Exercise 7.2.8: Using the charAt) method, write and run a Java program that rea tring and prints the string in reverse order. (Tip: Once the string has been entere aved, retrieve and display characters starting from the end of the string). Write a Java program that has 3 buttons. Clicking the first button shows the message "See no evil", clicking the second button shows the message "Hear no evil", clicking the third button shows the message "Speak...
In the following graph, write a Java program using Topological
Sort.
please write java code and show me the output.
Thank you :)
b.
Use the python erypto library to demonstrate how to encrypt and decrypt a message using AES n ECB mode. The python interrupter is installed by default with Kali Linux Take screenshots of command walkthrough and explain your steps Note: You will need to create a separate object for encryption and decryption similar to the example illustrate in the course slides You can also use pydoc command to view the documentation for the library. For example if you type: pydoc Crypto.cCipher.AEs...