java¼ÆËãÎļþºÍ×Ö·û´®µÄmd5Âë
import java.io.File;
import java.io.FileInputStream;
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class MD5Util
{
private static char md5Chars[] =
{ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd',
'e', 'f' };
private static MessageDigest messagedigest;
/*»ñÈ¡Ò»¸öÎļþµÄmd5Âë */
public static String getFileMD5String(File file) throws Exception
{
messagedigest = MessageDigest.getInstance("MD5");
FileInputStream in = new FileInputStream(file);
FileChannel ch = in.getChannel();
MappedByteBuffer byteBuffer = ch.map(FileChannel.MapMode.READ_ONLY, 0,
file.length());
messagedigest.update(byteBuffer);
return bufferToHex(messagedigest.digest());
}
/*»ñÈ¡Ò»¸ö×Ö·û´®µÄmd5Âë */
public static String getStringMD5String(String str) throws Exception
{
messagedigest = MessageDigest.getInstance("MD5");
messagedigest.update(str.getBytes());
return bufferToHex(messagedigest.digest());
}
/*ÑéÖ¤Ò»¸ö×Ö·û´®ºÍÒ»¸öMD5ÂëÊÇ·ñÏàµÈ */
public static boolean check(String str,String md5) throws Exception
{
if(getStringMD5String(str).equals(md5))
return true;
else
return false;
}
/*ÑéÖ¤Ò»¸öÎļþºÍÒ»¸öMD5ÂëÊÇ·ñÏàµÈ */
public static boolean check(File f,String md5) throws Exception
{
if(getFileMD5String(f).equals(md5))
return true;
else
return false;
}
private static String bufferToHex(byte bytes[])
{
return bufferToHex(bytes, 0, bytes.length);
}
private static String bufferToHex(byte b
Ïà¹ØÎĵµ£º
×î½üÓöµ½Ò»¸öÐèÇóÒªÔÚlinuxÏÂÓÃjava µ÷ÓÃmysql¿Í»§¶ËÔ¶³ÌµÇ½mysql·þÎñÆ÷£¬´Ó¿Í»§¶Ë»úÆ÷µ¼Èëmysql½Å±¾£¬´Ómysql·þÎñÆ÷¶Ëµ¼³ö±íÖеÄÊý¾Ý¡£ÒÔÏÂÊÇÓõ½µÄÖ÷Òª·½·¨£º
Java ´úÂë
/**
* µ¼ÈëÊý¾Ý
* @param ½Å±¾µÄµØÖ·ºÍÃû³Æ
* @return ÊÇ·ñ³É¹¦&nb ......
½ñÌìÓöµ½ÕâÑùµÄÎÊÌâ¡£ÐèÒªÏÂÔØÒ»¸öÎļþ£¬¸ÃÎļþµÄurlÈçÏ£º hxxp://www.abc.com/view/img/%E7%BD%91%E4%B8%8A%E8%B4%AD%E7%89%A9.rar
´ËÁ´½ÓÔÚä¯ÀÀÆ÷Ï»áÖض¨Ïòµ½±ðµÄÍøÕ¾¡£ËùÒÔÏÂÔØÏÂÀ´µÄÎļþ²¢·ÇÎÒÏëÒªµÄ¡£²éÁËÏÂÔÀ´ÊÇurl±àÂëºóµÄÎļþÃû¡£ÄÇôҪÏëÏÂÔؾͱØÐë¶ÔÕâ¸ö±àÂë½øÐнâÂë¡£¡£¡£¡£¡£
& ......
java_home
C:\Program Files\Java\jdk1.6.0_16
Path
%java_home%\bin;%java_home%\lib;
classpath
%java_home%\lib\dt.jar;%java_home%\lib\tools.jar;.;
java_home
C:\Program Files\Java\jdk1.6.0_16
Path
%SystemRoot%\system32;%java_home%\bin;%java_home%\lib;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\P ......
»·¾³: JDK 5.0 + Tomcat 5.5.4
JDK°²×°Â·¾¶: D:\Java\jdk1.5.0_01
Tomcat°²×°Â·¾¶:D:\Tomcat 5.5
ÉèÖû·¾³±äÁ¿(¿ØÖÆÃæ°å->ϵͳ->¸ß¼¶):
java_home=D:\Java\jdk1.5.0_01
path=%JAVA_HOME%\bin
classpath=.;D:\Java\jdk1.5.0_01\lib\dt.jar;D:\Java\jdk1.5.0_01\lib\tools.jar;D:\Tomcat 5.5\common\lib\se ......
Ê×ÏȽéÉÜÒ»ÏÂJavaScript£º
JavaScirpt ÊÇÒ»ÖÖ¿ÉÒÔÓÃÀ´¸øÍøÒ³Ôö¼Ó½»»¥ÐԵıà³ÌÓïÑÔ¡£³£³£»á¿´µ½JavaScript±»³ÆΪ“½Å±¾ÓïÑÔ”£¨Scripting language£©£¬Õⰵʾ×ÅËü¸üÊʺϱàд½Å±¾¶ø²»ÊdzÌÐò¡£Õâʵ¼ÊÉϲ¢Ã»Óиú²»ÉϵIJîÒì¡£JavaScript½Å±¾Ò²ÊÇÒ»ÖÖ³ÌÐò£¬Ëü°üº¬ÔÚHTMLÒ³ÃæÉÏ£¬ÒòΪ½Å±¾Îı¾°üΧÔÚ<Script>±êÇ©Ö ......