Java to PHP encryption and good secret

Source: Internet
Author: User
Tags log log
Java to PHP encryption and decryption
In the Userjsonutil class, add the
Encryptjsonuser () encryption, written as PHP encryption;
Decryptjsonuser () decryption, written as PHP decryption.



Package com.test.moltest;

Import java.util.Collection;
Import Java.util.Iterator;

Import Net.sf.json.JSONArray;
Import Net.sf.json.JSONObject;

Import Org.apache.commons.logging.Log;
Import Org.apache.commons.logging.LogFactory;

Import Com.capinfo.crypt.Md5;

/**
* Created by IntelliJ idea.
* user:bob_0703
* date:2008-10-18
* time:17:30:53
* To change this template use File | Settings | File Templates.
*/
public class Userjsonutil {

Private static final Log log = Logfactory.getlog ("Userjsonutil.class");

public static Boolean Decryptjsonuser (String s) {
Boolean rs = false;
try {
s = Destools.decrypt ("Testtest", s);//decryption 1

Jsonobject jobj = Jsonobject.fromobject (s);//Convert to JSON
Jsonarray Names=jobj.names ();
String md5str = (string) jobj.get ("MD5");//Get encrypted MD5

Names.remove (Names.size ()-1);
StringBuffer buf=new StringBuffer ();
Iterator It=names.iterator ();
while (It.hasnext ()) {
String Name=it.next ();
Buf.append (Jobj.get (name));
}

Jobj.remove ("MD5");
MD5 MD5 = new Md5 ("");
MD5.HMAC_MD5 (Buf.tostring (), "test");
byte b[] = Md5.getdigest ();
  • 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.