Here you can find the source of md5(String sInput)
Equivalent to (JavaSE): MessageDigest.getInstance("MD5").digest(sInput.getBytes()); Source: http://www.anavi.org/article/107/
public static byte[] md5(String sInput) throws NoSuchAlgorithmException, DigestException
//package com.java2s; /*/*from w w w . ja v a 2s. c om*/ * Copyright (C) 2008 onwards University of Deusto * * All rights reserved. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. * * This software consists of contributions made by many individuals, * listed below: * * Author: Aitor G?mez Goiri <aitor.gomez@deusto.es> */ import java.security.DigestException; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { /** * Equivalent to (JavaSE): * MessageDigest.getInstance("MD5").digest(sInput.getBytes()); * * Source: http://www.anavi.org/article/107/ */ public static byte[] md5(String sInput) throws NoSuchAlgorithmException, DigestException { //MD5 digest length is 128b (32 characters) int nDigestLen = 16; byte[] PlainText = sInput.getBytes(); //Allocate memory for the encrypted text byte[] encryptedText = new byte[nDigestLen]; MessageDigest Cipher; Cipher = MessageDigest.getInstance("MD5"); Cipher.update(PlainText, 0, PlainText.length); Cipher.digest(encryptedText, 0, nDigestLen); //Convert result to hexidecimal return encryptedText; } }