Java Encryption Program Small example

Source: Internet
Author: User

1: A company uses a public telephone to pass data, and the data is a four-bit integer that is encrypted during delivery.

The encryption rules are as follows: Each digit is prefixed with 5, and the remainder is replaced with and divided by 10, then the first and fourth bits are exchanged, and the second and third bits are exchanged.

Package Cn.zzsxt.lianxi;
Import Java.util.Scanner;
public class Practice {
public static void Main (string[] args) {
System.out.println ("Please enter a four-digit number:");
Scanner input = new Scanner (system.in);
int num = Input.nextint ();
int ge=num%10;
int shi=num/10%10;
int bai=num/100%10;
int qian=num/1000;

Ge= (ge+5)%10;
Shi= (shi+5)%10;
Bai= (bai+5)%10;
Qian= (qian+5)%10;

int tem=ge;
Ge=qian;
Qian=tem;

Tem=shi;
Shi=qian;
Qian=tem;
System.out.println ("Post-encryption number" +ge+shi+bai+qian);
}
}

Java Encryption Program Small example

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.