MD5: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 18: Line 18:


==Java==
==Java==
{{External|https://github.com/NovaOrdis/playground/tree/master/java/security/encryption}}


<syntaxhighlight lang='java'>
<syntaxhighlight lang='java'>

Revision as of 08:12, 6 May 2018

External

Internal

Overview

MD5 is a cryptographically secure message digest algorithm. It takes an arbitrary-sized input - a byte array - and generates a fixed size output, called a digest or hash. MD5 produces a 16 byte digest.

Computing MD5

OpenSSL

An MD5 hash can be generated with OpenSSL.

Java

https://github.com/NovaOrdis/playground/tree/master/java/security/encryption
import java.security.MessageDigest;

public static byte[] getMD5(byte[] b) throws Exception {

    MessageDigest md = MessageDigest.getInstance("MD5");
    return md.digest(b);
}