Question

In: Computer Science

1. A company that wants to send data over the Internet will use an encryption program...

1. A company that wants to send data over the Internet will use an encryption program to ensure data security. All data will be transmitted as four-digit integers. The application should read a four-digit integer entered by the user and encrypt it as follows:  Replace each digit with the remainder of the new value divided by 10 by adding 6 to the digit. Then replace the number in the first digit with the third, and the number in the second digit with the fourth. Print the encrypted integer on the screen.  Write a separate application where an encrypted four-digit integer is entered and decrypted (reversing the encryption scheme) and finds the original number.

Note: code should be written in Java Language.

Solutions

Expert Solution

import java.util.*;

public class Main
{
        public static void main(String[] args) {
            Scanner sc= new Scanner(System.in);
                System.out.println("Enter a 4-digit number");
                int n= sc.nextInt();    //input of the number
                int ar[]=new int[4];   //array to store all digits
                int i=3;       //counter variable
                
                while(n>0)     //loop to store each digit in the array
                {
                    ar[i]=n%10;
                    n/=10;
                    i--;
                }
                for( i=0;i<4;i++)    //loop to calculate the original digit of the number
                {
                    ar[i]= (ar[i]+6)%10;
                }
                
                int temp=ar[2];   //swapping 1st and 3rd digit
                ar[2]=ar[0];
                ar[0]=temp;
                
                temp=ar[3];      //swapping 2nd and 4th digit
                ar[3]=ar[1];
                ar[1]=temp;
                
                System.out.println("The original number is :");
                for( i=0;i<4;i++)                  //loop to ptint original digits of the number.
                System.out.print(ar[i]);   
        }
}

Related Solutions

1) A company that wants to send data over the Internet will use an encryption program...
1) A company that wants to send data over the Internet will use an encryption program to ensure data security. All data will be transmitted as four-digit integers. The application should read a four-digit integer entered by the user and encrypt it as follows:  Replace each digit with the remainder of the new value divided by 10 by adding 6 to the digit. Then replace the number in the first digit with the third, and the number in the...
1. A company that wants to send data over the Internet will use an encryption program...
1. A company that wants to send data over the Internet will use an encryption program to ensure data security. All data will be transmitted as four-digit integers. The application should read a four-digit integer entered by the user and encrypt it as follows:  Replace each digit with the remainder of the new value divided by 10 by adding 6 to the digit. Then replace the number in the first digit with the third, and the number in the...
1. A company that wants to send data over the Internet will use an encryption program...
1. A company that wants to send data over the Internet will use an encryption program to ensure data security. All data will be transmitted as four-digit integers. The application should read a four-digit integer entered by the user and encrypt it as follows:  Replace each digit with the remainder of the new value divided by 10 by adding 6 to the digit. Then replace the number in the first digit with the third, and the number in the...
1. A company that wants to send data over the Internet will use an encryption program...
1. A company that wants to send data over the Internet will use an encryption program to ensure data security. All data will be transmitted as four-digit integers. The application should read a four-digit integer entered by the user and encrypt it as follows:  Replace each digit with the remainder of the new value divided by 10 by adding 6 to the digit. Then replace the number in the first digit with the third, and the number in the...
A company that wants to send data over the Internet has asked you to write a...
A company that wants to send data over the Internet has asked you to write a program that will encrypt it so that it may be transmitted more securely. All the data is transmitted as four-digit integers. Your application should read a four-digit integer entered by the user and encrypt it as follows: Replace each digit with the result of adding 7 to the digit and getting the remainder after dividing the new value by 10. Then swap the first...
A company that wants to send data over the Internet has asked you to write a...
A company that wants to send data over the Internet has asked you to write a program that will encrypt it so that it may be transmitted more securely. All the data is transmitted as four-digit integers. Your application should read a four-digit integer entered by the user and encrypt it as follows: Replace each digit with the result of adding 7 to the digit and getting the remainder after dividing the new value by 10. Then swap the first...
For encryption, what does it mean for data to be in transition and in use? What...
For encryption, what does it mean for data to be in transition and in use? What are the major security concerns with data encryption?
If two applications use TCP to send data but only send 10 bytes per segment (e.g....
If two applications use TCP to send data but only send 10 bytes per segment (e.g. by using the push operation), what is the maximum percent of the network bandwidth they will have for their data?
At Transport layer of Networks, we use segments to send data across. 1. Argue for using...
At Transport layer of Networks, we use segments to send data across. 1. Argue for using larger segments by discussing briefly why larger segments could be beneficial. 2. Then also argue why using small segments may be beneficial.
Write a program using interrupts to get data serially and send it to P2 while at...
Write a program using interrupts to get data serially and send it to P2 while at the same time Timer 0 is generating a square wave of 5 kHz. We've been basing our code on the Intel 8051 microntroller and assembly language.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT