Answered step by step
Verified Expert Solution
Question
1 Approved Answer
i dont want a code written purely in C i need a code written in JAVA help me please!!! This Program is written purely in
i dont want a code written purely in C
i need a code written in JAVA
help me please!!!
This Program is written purely in Java!
instructions
A code in JAVA! thats all im asking
import java.util.Scanner; import java.security SecureRandom; import java.math.Biglnteger; class XOR public static void main (String args) try f //Read a line from keyboard Scanner in new Scanner(System.in)://define scanner for input String messageString: System.out.printin("Please enter the message:"l; messageString-in.nextline)://read a line System.out.printin("Original Message: "+ messageString): Biginteger message convertStringToBigintegerlmessageString): //Set up a secure random number generator SecureRandom random SecureRandomgetlnstanceCHAPRNG"); int seed 10; random.setseed(seed); //initilize the random number generator //Generate Key (Warning! botched) byte I keyStream new byte[2) random.nextBytes(keyStream)://generate random bytes in put in keyStream Biginteger key new Biginteger(keyStream) /IXOR encryption - Sender's (Alice's) end Biginteger cipherText message.xor(key): //Convert ciphertext to a string so that we can print it System.out.println("plaintext (in binary):"+ message.toString(2)://displays message in binary System.out.printin("key (in binary):" + key.toString(2): //displays key in binary System.out.println("ciphertext (in binary):" + cipherText.toString(2)): //displays ciphertext in binary System.out.printin("Ciphertext (in characters): "+ convertBigintegerToString(cipherText)): //XOR decryption Receiver's end (Bob's end Biginteger receivedMessage cipherText.xor(keyl String receivedMessageString convertBigintegerToString(receivedMessage); System.out.printin( Received Message: "+ receivedMessageString); catch (Exception e) e.printStackTrace): //This is a method to convert a String to Biginteger by //packing each character of the String into a Biginteger //Input: String //Return Value: Biginteger public static Biginteger convertStringToBiginteger(String s) Biginteger b new Bigintegerfo") for (int i 0; i Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started