Java characters sorted alphabetically-stitching-MD5 Encryption-Uppercase

Source: Internet
Author: User
Tags md5 digest md5 encryption

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

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.