jsp中当然也有啊,你可以直接写成一个javabean中的一个函数
public String generatemd5string(String csinput)
{
byte[] b, b2 ;
StringBuffer buf ;
String csreturn = null ; try
{
b = csinput.getBytes("iso-8859-1") ;
MessageDigest md = MessageDigest.getInstance("MD5") ;
md.update(b) ;
b2 = md.digest() ; buf = new StringBuffer(b2.length * 2) ;
for (int nLoopindex = 0 ; nLoopindex < b2.length ; nLoopindex++)
{
if ( ( (int) b2[nLoopindex] & 0xff) < 0x10)
{
buf.append("0") ;
}
buf.append(Long.toString( (int) b2[nLoopindex] & 0xff, 16)) ;
}
csreturn = new String(buf) ;
}
catch (Exception e)
{
e.printStackTrace() ;
csreturn = null ;
} return csreturn ;
}
public String generatemd5string(String csinput)
{
byte[] b, b2 ;
StringBuffer buf ;
String csreturn = null ; try
{
b = csinput.getBytes("iso-8859-1") ;
MessageDigest md = MessageDigest.getInstance("MD5") ;
md.update(b) ;
b2 = md.digest() ; buf = new StringBuffer(b2.length * 2) ;
for (int nLoopindex = 0 ; nLoopindex < b2.length ; nLoopindex++)
{
if ( ( (int) b2[nLoopindex] & 0xff) < 0x10)
{
buf.append("0") ;
}
buf.append(Long.toString( (int) b2[nLoopindex] & 0xff, 16)) ;
}
csreturn = new String(buf) ;
}
catch (Exception e)
{
e.printStackTrace() ;
csreturn = null ;
} return csreturn ;
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货