MD5 Decryption and encryption algorithm

Source: Internet
Author: User

Http://md5.tellyou.top/default.html

public class Md5andkl {

MD5 overweight. 32 Guests
public static string MD5 (String inStr) {
MessageDigest MD5 = NULL;
try {
MD5 = messagedigest.getinstance ("MD5");
} catch (Exception e) {
System.out.println (E.tostring ());
E.printstacktrace ();
Return "";
}
char[] Chararray = Instr.tochararray ();
byte[] ByteArray = new Byte[chararray.length];

for (int i = 0; i < chararray.length; i++)
Bytearray[i] = (byte) chararray[i];

byte[] md5bytes = Md5.digest (ByteArray);

StringBuffer hexvalue = new StringBuffer ();

for (int i = 0; i < md5bytes.length; i++) {
int val = ((int) md5bytes[i]) & 0xFF;
if (Val < 16)
Hexvalue.append ("0");
Hexvalue.append (Integer.tohexstring (Val));
}

return hexvalue.tostring ();
}

Reversible encryption algorithm
public static string KL (String inStr) {
string s = new string (INSTR);
Char[] A = Instr.tochararray ();
for (int i = 0; i < a.length; i++) {
A[i] = (char) (a[i] ^ ' t ');
}
string s = new String (a);
return s;
}

Decryption after encryption
public static string JM (String inStr) {
Char[] A = Instr.tochararray ();
for (int i = 0; i < a.length; i++) {
A[i] = (char) (a[i] ^ ' t ');
}
String k = new String (a);
return k;
}

Test the main function
public static void Main (String args[]) {
string s = new String ("123123");
4297f44b13955235245b2497399d7a93
System.out.println ("Original:" + s);
System.out.println ("After MD5:" + MD5 (s));
System.out.println ("MD5 after re-encryption:" + KL (MD5 (s));
System.out.println ("Decrypted for MD5:" + JM (KL (MD5 (s)));
}
}


MD5 Decryption and encryption algorithm

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.