Package yixin;
Import Java.security.MessageDigest;
Import Java.util.Arrays;
public class Data_change {
Static char[] hex_digits = {' 0 ', ' 1 ', ' 2 ', ' 3 ', ' 4 ', ' 5 ', ' 6 ', ' 7 ', ' 8 ', ' 9 ', ' A ', ' B ', ' C ', ' d ', ' e ', ' f '}; Hex_digits is 16 binary characters
/*
* Send Array
* Array Sorting
* Arrays are stitched into strings
*/
public string Sortletter (string [] input) {
Arrays.sort (Input,string.case_insensitive_order);
System.out.println ("sorted string:" +arrays.tostring (input));
StringBuilder _SB = new StringBuilder ();
for (int i=0;i<input.length;i++) {
_sb.append (Input[i]);
}
Return _sb.tostring (). ReplaceAll ("=", "");
}
/*
* Pass Key
*/
public string Inputkey (string x) {
return x;
}
/*
* MD5
*/
Public final static String MD5 (string s) {
try {
byte[] Btinput = S.getbytes ();
MessageDigest object for obtaining the MD5 digest algorithm
MessageDigest mdinst = messagedigest.getinstance ("MD5");
Updates the digest with the specified bytes
Mdinst.update (Btinput);
Get ciphertext
byte[] MD = Mdinst.digest ();
Convert ciphertext to 16-binary string form
int j = Md.length;
Char str[] = new CHAR[J * 2];
int k = 0;
for (int i = 0; i < J; i++) {
byte byte0 = md[i];
str[k++] = hex_digits[byte0 >>> 4 & 0xf];
str[k++] = hex_digits[byte0 & 0xf];
}
return new String (str);
} catch (Exception e) {
E.printstacktrace ();
return null;
}
}
public static void Main (string[] args) {
Data_change t = new Data_change ();
StringBuilder _STRB = new StringBuilder ();
_strb.append ("account="). Append ("Shuzun"). Append (",");
_strb.append ("orderid="). Append ("shuzun123456789"). Append (",");
_strb.append ("card="). Append ("6200000000000000"). Append (",");
_strb.append ("Name="). Append ("Zhang San"). Append (",");
_strb.append ("index="). Append ("a001,b002,c001"). Append (",");
_strb.append ("identitycard="). Append ("340826201505141812"). Append (",");
_strb.append ("mobile="). Append ("13888888888"). Append (",");
String input=_strb.tostring ();
SYSTEM.OUT.PRINTLN ("Get Input:" +input);
string[] arr = input.split ("\ \,"); Cutting array
System.out.println ("Get the array After:" +arrays.tostring (arr));
String return_string = T.sortletter (arr);
System.out.println ("sorted string after concatenation:" +return_string);
String Return_x=t.inputkey ("55884yuu11");
String newstr=return_string+return_x;
System.out.println ("Add key after the new string:" +newstr);
@SuppressWarnings ("Static-access")
String return_newstr= t.md5 (NEWSTR);
SYSTEM.OUT.PRINTLN ("MD5 display after encryption:" +RETURN_NEWSTR);
String return_bigstr= return_newstr.touppercase ();
System.out.println ("Converted to uppercase:" +RETURN_BIGSTR);
}
}
Java characters sorted alphabetically-stitching-MD5 Encryption-Uppercase