谁在说PHP垃圾我跟谁看看以下代码谁牛B?

WBOY
Release: 2016-06-21 08:45:32
Original
836 people have browsed it

Java代码

public static String getMD5(String orgin, String charset) {	if (charset == null) charset = "utf-8";	String result = null;	try {		MessageDigest md = MessageDigest.getInstance("MD5");		result = byte2hex(md.digest(orgin.getBytes(charset)));	} catch (Exception e) {		throw new java.lang.RuntimeException("sign error !", e);	}	return result;}private static String byte2hex(byte[] b){	StringBuffer hs = new StringBuffer(); 	String stmp = ""; 	for (int n = 0; n < b.length; n++) { 		 stmp = (java.lang.Integer.toHexString(b[n] & 0XFF)); 		 if (stmp.length() == 1) 		 hs.append("0").append(stmp); 		 else 		 hs.append(stmp); 	 } 	 return hs.toString();}public static String encode(byte[] srcContent) {	if(srcContent == null) {		return null;	}	//的实现会每76个字符后面增加一个回车,需要删除。	return new BASE64Encoder().encode(srcContent).replace("\r\n", "");}String data = "helloword";String secret = "123456";String md5Value = Md5Util.getMD5(data + secret);String reSign = Base64Util.encode(md5Value.getBytes("utf-8")); //结果reSign=Y2UyMTllODgzNTVmMmYzYzI3NTEwOWM0OWY1YTVmMjU=
Copy after login

PHP代码

$reSign = base64_encode(md5($data.$secret))
Copy after login
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template