jsp 에서 암호화 md5 하는 방법

<%!

private String getMD5( String strVal )

{

 StringBuffer sb = new StringBuffer();

 try

 {

  byte[] digest = java.security.MessageDigest.getInstance("MD5").digest( strVal.getBytes() );

  sb.setLength(0);

  for( int i = 0; i < digest.length; i++ ) { 

   sb.append( Integer.toString( ( digest[i] & 0xf0) >> 4, 16 ) ); 

   sb.append( Integer.toString( digest[i] & 0x0f, 16 ) );

  }

  return sb.toString();

 }

 catch( Exception ex )

 {

  return "";

 }

}

%>

 

<%

String str = "123";

String str1 = getMD5( str );

%>

<%= str1 %>

출처 : http://imjusti.egloos.com/viewer/2195032


DB로 입력할때 쿼리문

MSSQL

SELECT SUBSTRING(MASTER.dbo.FN_VARBINTOHEXSTR(HashBytes('MD5', '데이터 내용')), 3, 32)


mysql

select md5("123")



오라클 ???

+ Recent posts