-
-
Save chocotan/93660ea2af5ba5ce155968e3fee4996e to your computer and use it in GitHub Desktop.
ZTO接口签名方式
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var checkBytes = Encrypt.GetMd5HashBytes(data + key, encoding); | |
var dataDigest = Convert.ToBase64String(checkBytes); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.apache.commons.codec.binary.Base64; | |
import org.apache.commons.codec.digest.DigestUtils; | |
import java.nio.charset.Charset; | |
public class DigestUtil { | |
public static String md5WithBase64(String str, String charset) { | |
return base64(md5Bytes(str, charset)); | |
} | |
public static String base64(byte[] bytes) { | |
return Base64.encodeBase64String(bytes); | |
} | |
public static byte[] md5Bytes(String str) { | |
return md5Bytes(str, "UTF-8"); | |
} | |
public static byte[] md5Bytes(String str, String charset) { | |
return DigestUtils.md5(str.getBytes(Charset.forName(charset))); | |
} | |
public static String md5Str(String str) { | |
return DigestUtils.md5Hex(str); | |
} | |
public static String md5Str(String str, String charset) { | |
return DigestUtils.md5Hex(str.getBytes(Charset.forName(charset))); | |
} | |
public static String decodeBase64(String content) { | |
return new String(Base64.decodeBase64(content)); | |
} | |
public static String decodeBase64(String content, String encode) { | |
return new String(Base64.decodeBase64(content), Charset.forName(encode)); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$data="你好"; | |
$key="签名"; | |
$data_digest = base64_encode(md5($data.$key,TRUE)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
java版的签名用 md5WithBase64方法