ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • [java] MD5
    카테고리 없음 2022. 6. 14. 11:08
    반응형

    MD5 

    param = 암호화하려는 문자열

    public static String getMD5(String str){
            String rtnMD5 = "";
            try {
                
                MessageDigest md = MessageDigest.getInstance("MD5");
              
                md.update(str.getBytes());
               
                byte byteData[] = md.digest();
                StringBuffer sb = new StringBuffer();
               
                for(byte byteTmp : byteData) {
                    sb.append(Integer.toString((byteTmp&0xff) + 0x100, 16).substring(1));
                }
                rtnMD5 = sb.toString();
            } catch (Exception e) {
                e.printStackTrace(); 
                rtnMD5 = null; 
            }
            return rtnMD5;
        }
    반응형

    댓글

Designed by Tistory.