Java로 MD5 구현 하기


import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class MD5Hash {
    private static MessageDigest md;

    static {
        try {
            md = MessageDigest.getInstance("MD5");
        } catch (NoSuchAlgorithmException e) {
            // do nothing
        }
    }

    public static byte[] encode(String str) {
        if (str == null) {
            return null;
        }

        return digest(str.getBytes());
    }

    public static byte[] encode(byte[] bytes) {
        if (bytes == null) {
            return null;
        }

        return digest(bytes);
    }

    private static byte[] digest(byte[] msg) {
        md.reset();
        return md.digest(msg);
    }
}

'programming > java' 카테고리의 다른 글

XOM 시작하기(Creating XML Documents)  (0) 2008.09.18
XOM 소개  (0) 2008.09.18
SystemProp.java  (0) 2008.09.18
자바에서 AES 암호화 알고리즘 사용하기  (0) 2008.09.18
Java SE 6 새로운 기능  (0) 2007.11.09

Java SE 6 새로운 기능

출처 : https://java.sun.com/javase/6/features.jsp
 
 
 
New Security Features and Enhancements

    * Native platform Security (GSS/Kerberos) integration.
    * Java Authentication and Authorization Service (JAAS) login module that employs LDAP authentication
    * New Smart Card I/O API


Integrated Web Services

    * New API for XML digital signature services for secure web services
    * New Client and Core Java Architecture for XML-Web Services (JAX-WS) 2.0 APIs
    * New support for Java Architecture for XML Binding (JAXB) 2.0


Scripting Language Support (JSR 223)

    * New framework and API for scripting languages
    * Mozilla Rhino engine for JavaScript built into the platform


Enhanced Management and Serviceability

    * Improved JMX Monitoring API
    * Runtime Support for dTrace (Solaris 10 and future Solaris OS releases only)
    * Improved memory usage analysis and leak detection


Increased Developer Productivity

    * JDBC 4.0 support (JSR 221)
    * Significant library improvements
    * Improvements to the Java Platform Debug Architecture (JPDA) & JVM Tool Interface



Improved User Experience

    * look-and-feel updates to better match underlying operating system
    * Improved desktop performance and integration
    * Enhanced internationalization support


'programming > java' 카테고리의 다른 글

XOM 시작하기(Creating XML Documents)  (0) 2008.09.18
XOM 소개  (0) 2008.09.18
SystemProp.java  (0) 2008.09.18
자바에서 AES 암호화 알고리즘 사용하기  (0) 2008.09.18
Java로 MD5 구현 하기  (0) 2008.09.18