Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

For these exercises we will be Alice. We want to encrypt a message to send to Bo

ID: 1811189 • Letter: F

Question

For these exercises we will be Alice. We want to encrypt a message to send to Bob. For simplicity the message consists of a single word - ENIGMA. Our private key is a=5. Bob has a private key also. The following public keys are published: C=3, and N=13.

STEP 1: Encode the message into binary by translating each letter into a 5-bit binary sequence designating the numerical position of the letter in the alphabet.
For example, an N is the 14th letter in the alphabet. (14)10=(01110)2.

binary representation:  (use 30 bits and do not put spaces between binary digits)

STEP 2: Establish the codeword P (in decimal) that will be sent to Bob using the algorithm P=Camod(N).

P =

STEP 3: We have transmitted P (from STEP 2) to Bob and he has sent us the number Q=3. He computed this number using his private key. Using this information, compute the seed X(0) that will be used in the pseudo-random number generator in the next step.

X(0) =

STEP 4: Generate a binary encryption string that is as long as the message. Use the algorithm X(n+1)=[11*X(n)+7] mod(16) to generate random numbers. Repeating as many times as necessary to generate a string with as many bits as the message. Remember X(0) is the codeword that you and Bob established in STEP 3. Notice that the N value of PRNG (it is here 16) is not the same here as N used for the generation of X(0) (it was 13). You will first write the sequence of pseudo random numbers in decimal, and then in binary.

Pseudo-Random number sequence (in decimal):  (start the sequence with X(1), and leave 1 space between each decimal number; only write as many decimal numbers as you will need for the encryption string--think ahead)

Now, translate each of the decimal digits into a 4-bit binary sequence and combine them to form the encryption string. Why 4 bits?

Encryption string (in binary):  (start the sequence with X(1), no spaces, and leave out any unecessary bits at the end; you only need 30 bits, the length of the message to encrypt)

STEP 5: Encrypt the message with the exclusive-or operation

Tries 0/4

Explanation / Answer

THIS WILL CLEAR UR CONCEPT AND U WILL SOLVE IT BY URSELF. COMMENT IF IT IS NOT HELPFUL. RATE PLZ.

Introduction

Imagine you have a series of numbers, such these: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, and 20. Imagine you want to select one of these numbers, any of them. A number is referred to as random if it has been selected from a pool without a specific pattern to follow. For example, if you decide to select the value 17 from this list, if there was an exact reason that number was selected, then it is not considered random. In reality, it is difficult for a number to qualify as random. For this reason, most random numbers are referred to as pseudo-random.

Getting a Random Number

To support the ability to create or choose a random number, the java.util package contains a class named Random. To start, you can declare a variable of this class, using one of its two constructors. Here is an example that uses the default constructor:

After declaring the variable, you can start getting numbers from it. The Random class allows you to get a Boolean value, a normal integer, a long integer, or a decimal value. To assist with this, the Random class provides the following methods:

Here is an example of calling one of these methods:

Here is an example of running the program:

In the same way, you can call the method repeatedly to get random numbers. Here is an example:

Here is an example of running the program:

The Seed of a Random Number

Consider the following program:

Here is an example of running the program:

Here is another example of running the same program:

Notice that the numbers generated are different. When creating a program that repeatedly gets a series of random numbers, you may (or may not) want the Random class to generate the same number over and over again. A seed is a constant value that controls whether a random generation would produce the same result every time it occurs. For example, using a seed, you can impose it upon the Random class to generate the same number every time the nextInt() method is called. To support the ability to use a seed, the Random class is equipped with a second constructor whose syntax is:

Based on this, to specify a seed, when declaring a Random variable, pass a constant integer to the constructor. Here is an example:

Here is one example of running the program:

Here is another example of running the same program:

Notice that the numbers are the same. Consider this program also:

Here is one example of running the program:

Here is another example of running the same program:

Notice that the sequences are the same. In both cases, this indicates that, if you specify a seed, the Random class would generate the same number or the same sequence of numbers.

Besides the second constructor, to specify the seed, you can call the setSeed() method. Its syntax is:

This method takes one argument as the seed. Here is an example of calling it:

Generating Random Numbers in a Range of Numbers

So far, we have been using any number that would fit an integer. In some assignments, you may want to restrict the range of numbers that can be extracted. The Random class can assist with this. Using the Random class, you can generate random positive numbers from 0 (included) to a maximum (excluded) of your choice. To support this, the Random class is equipped with another version of the nextInt() method whose syntax is:

The argument to pass to the method determines the highest integer that can be generated by the nextInt() method. The method returns an integer. Here is an example that generates random numbers from 0 to 20:

Here is an example of running the program:

The above version of the Next() method generates numbers starting at 0.

The Math.Random Method

Besides the Random class, the Math class is equipped with a method that can be used to generate random numbers. The syntax of this method is:

When called, this method produces a randomly selected decimal number between 0.00 (included) and 1.00 (excluded).

Introduction



Imagine you have a series of numbers, such these: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, and 20. Imagine you want to select one of these numbers, any of them. A number is referred to as random if it has been selected from a pool without a specific pattern to follow. For example, if you decide to select the value 17 from this list, if there was an exact reason that number was selected, then it is not considered random. In reality, it is difficult for a number to qualify as random. For this reason, most random numbers are referred to as pseudo-random.

Getting a Random Number


To support the ability to create or choose a random number, the java.util package contains a class named Random. To start, you can declare a variable of this class, using one of its two constructors. Here is an example that uses the default constructor:

  import java.util.Random;    public class Exercise {      public static void main(String[] args) {          Random rndNumber = new Random();      }  }  

After declaring the variable, you can start getting numbers from it. The Random class allows you to get a Boolean value, a normal integer, a long integer, or a decimal value. To assist with this, the Random class provides the following methods:

Method Produces
  boolean nextBoolean();  
A true or false value
  int nextInt()  
An integral value between Integer.MIN_VALUE and Integer.MAX_VALUE
  long nextLong()  
A long integral value between Long.MIN_VALUE and Long.MAX_VALUE
  float nextFloat()  
A decimal number between 0.0 (included) and 1.0 (excluded)
  double nextDouble()  
A decimal number between 0.0 (included) and 1.0 (excluded)

Here is an example of calling one of these methods:

  import java.util.Random;    public class Exercise {      public static void main(String[] args) {          Random rndNumbers = new Random();          int    rndNumber  = rndNumbers.nextInt();            System.out.println("Number: " + rndNumber);      }  }  

Here is an example of running the program:

  Number: 1369872590  

In the same way, you can call the method repeatedly to get random numbers. Here is an example:

  import java.util.Random;    public class Exercise {      public static void main(String[] args) {          Random rndNumbers = new Random();          int rndNumber = 0;            for (int nbr = 1; nbr < 9; nbr++) {              rndNumber = rndNumbers.nextInt();              System.out.println("Number: " + rndNumber);          }      }  }  

Here is an example of running the program:

  Number: 1783601039  Number: -646235293  Number: -57529965  Number: 983241665  Number: 1794072434  Number: 1797572448  Number: 1057090973  Number: -634503464  

The Seed of a Random Number


Consider the following program:

  import java.util.Random;    public class Exercise {      public static void main(String[] args) {          Random rndNumbers = new Random();          int rndNumber = rndNumbers.nextInt();            System.out.println("Number: " + rndNumber);      }  }  

Here is an example of running the program:

  Number: 573991745  

Here is another example of running the same program:

  Number: 334223329  

Notice that the numbers generated are different. When creating a program that repeatedly gets a series of random numbers, you may (or may not) want the Random class to generate the same number over and over again. A seed is a constant value that controls whether a random generation would produce the same result every time it occurs. For example, using a seed, you can impose it upon the Random class to generate the same number every time the nextInt() method is called. To support the ability to use a seed, the Random class is equipped with a second constructor whose syntax is:

  public Random(long Seed);