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

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?
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.
C++. How do I reverse this encryption? Here is the question: "A company that wants to...
C++. How do I reverse this encryption? Here is the question: "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 program should read a four-digit integer in main() entered by the user and encrypt it as follows: 1. Replace each digit with the result of adding 7 to the digit and...
Internet Marketing: Whats internet Marketing? Discuss an existing company that use internet marketing? how it use...
Internet Marketing: Whats internet Marketing? Discuss an existing company that use internet marketing? how it use Internet marketing to promote one of its products? which product and why? what are the benefit of internet marketing ? Support Information: As in any new industry or concept, the Internet has its share of confusing buzzwords and jargon. A website produced by Matisse Enzer, presents a comprehensive glossary of Internet terms. http://www.matisse.net/files/glossary.html Many traditional elements of marketing easily translate into Internet marketing such...
SnoopPro is a global company specializing in communications security. The company monitors over 1 billion Internet...
SnoopPro is a global company specializing in communications security. The company monitors over 1 billion Internet messages per day and recently reported that 70% of emails are spam. Suppose your inbox contains 25 messages. Let X be the number of messages that are spam. What is P(16 ≤ X ≤ 20)? If a sample of size n = 64 is selected from a population with mean E(X) = 50 and standard deviation SD(X) = 8, then the probability that the...
A company wants to transmit data over the telephone but is concerned that its phones could be tapped
A company wants to transmit data over the telephone but is concerned that its phones could be tapped. All of the data are transmitted as four-digit integers. The company has asked you to write a program that encrypts the data so that it can be transmitted more securely. Your program should read a four-digit integer and encrypt it as follows: Replace each digit by (the sum of that digit plus 7) modulus 10. Then, swap the first digit with the...
Data Encryption (Strings and Bitwise Operators) Write a C program that uses bitwise operators (e.g. bitwise...
Data Encryption (Strings and Bitwise Operators) Write a C program that uses bitwise operators (e.g. bitwise XOR) to encrypt/decrypt a message. The program will prompt the user to select one of the following menu options: 1. Enter and encrypt a message 2. View encrypted message 3. Decrypt and view the message (NOTE: password protected) 4. Exit If the user selects option 1, he/she will be prompted to enter a message (a string up to 50 characters long). The program will...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT