Convert the input parameter string waitforsignstring to a binary array, encoded with UTF-8 (Java code such as: Waitforsignstring.getbyte ("Utf-8")), The binary Format data (waitforsignbytes) that is signed into the parameter is obtained.
The Waitforsignbytes is digest signed using the MD5,SHA1 or Sha256 algorithm. Get signed in result binary array data (signaturebytes)
A 16-character string encoding of the result binary array (signaturebytes) of the signature output, resulting in a final signature string (signature)
Algorithm expression:
String signature = Hex (Digest (Stringtosign+secretkey)) where the digest algorithm can be: MD5, Sha256hex
How should this signature algorithm be implemented in PHP? PHP MD5 does not seem to be able to manipulate arrays ....
Reply content:
Convert the input parameter string waitforsignstring to a binary array, encoded with UTF-8 (Java code such as: Waitforsignstring.getbyte ("Utf-8")), The binary Format data (waitforsignbytes) that is signed into the parameter is obtained.
The Waitforsignbytes is digest signed using the MD5,SHA1 or Sha256 algorithm. Get signed in result binary array data (signaturebytes)
A 16-character string encoding of the result binary array (signaturebytes) of the signature output, resulting in a final signature string (signature)
Algorithm expression:
String signature = Hex (Digest (Stringtosign+secretkey)) where the digest algorithm can be: MD5, Sha256hex
How should this signature algorithm be implemented in PHP? PHP MD5 does not seem to be able to manipulate arrays ....
In PHP, strings are binary compatible and are encoded by default, and if your string itself is UTF-8 encoded, it is already a UTF-8 binary array.
The MD5 function in PHP can directly calculate the MD5 value of a string (that is, a binary array), and the default output is the result that has been converted to 16 binary.
So, in Java, what you want to do is to implement ...
In PHP, it is$md5 = md5('字符串');