Nonsense has been implemented in Java encryption phone number, there is a specific encryption process annotation this inside said, this article I directly on the code.
Please see:
/** * @Title: Testmain.java * @Package org.test * @Description: Todo The main role of the method: * @author a18ccms a18ccms_gmail_com *
Date 2017-5-29 pm 8:15:33 * @version V1.0 * * * Package org.test;
Import Java.util.Scanner;
Import Java.util.regex.Matcher;
Import Java.util.regex.Pattern; /** * * Project Name: Test * Class Name: Testmain * Class Description: Encryption * Creator: Mu Xiongxiong * Create time: 2017-5-29 8:15:33 * Modified person:
Mu Xiongxiong * Modified: 2017-5-29 8:15:33 * Modify NOTE: * @version * */public class Testmain {/** * * @Title: Main * @Description: * The most important role of this method: * The latest encryption method, the encryption of a number of encryption rules: first of all the numbers in descending order, and then add each number 5, * and divided by 10 of the remainder in place of the number, * and finally the first Number and last number exchanged, encryption complete * @param @param args Set file * @return return type: void * @throws/public static void Main (string[)
args) {//Encrypt System.out.println ("Please enter the number you want to encrypt:");
Scanner in = new Scanner (system.in);
String num = In.next ();
Pattern pattern = Pattern.compile ("[0-9]*");
Matcher isnum = Pattern.matcher (Num.trim ()); if (Isnum.matches (){///Execute encryption Method encrypt (NUM);
else {System.out.println ("Enter a number if not number");
}/** * * @Title: Encrypt * @Description: The main role of this method: * @param settings file * @return return type: void * @throws/ public static void Encrypt (string stunum) {String encrypt = ""; The encrypted string Yuan = ""; Swap position before int num = 0; Split into a single digit int snum = 0; After each number plus 5 int ynum = 0;
The remainder of each number and divided by 10 int n [] = new int[stunum.length ()];
for (int i = 0; i < n.length; i++) {N[i] = Integer.parseint (string.valueof (Stunum.charat (i)) to convert each number to type int; (int i = 0; i < n.length-1 i++) {for (int j = 0; J < n.length-1-I. J +) by bubbling Sort method
{if (N[j] < N[j + 1]) {int temp;
temp = N[j];
N[J] = n[j + 1];
N[j + 1] = temp;
for (int i = 0; i < n.length i++) {String cnum = n[i]+ ""; num = Integer.parseiNT (Cnum);
Carry out each number plus 5 snum = num+5;
Replace the number Ynum = snum% 6 with the remainder divided by 6;
The remainder num = ynum divided by 6;
Put each number in the yuan string yuan + = num;
///will last digit and first digit exchange position int m [] = new int[yuan.length ()];
for (int i = 0; i < m.length; i++) {M[i] = Integer.parseint (string.valueof (Yuan.charat (i)) to convert each number to type int;
}//Exchange position int fristnum = m[0];
M[0]= M[m.length-1];
M[m.length-1] = Fristnum;
for (int i = 0; i < m.length i++) {encrypt + = M[i];
///Put the encrypted array in the string System.out.println ("original phone number:" +stunum);
SYSTEM.OUT.PRINTLN ("Encrypted phone number:" +encrypt);
}
}
Welcome advice ...