document.write('<link rel="stylesheet" type="text/css" href="http://www.naslu.com/css/SyntaxHighlighter.css" />');
document.write('<p style="font-family: Arial;font-size:16px;color: #444444;font-weight: bold;">');
document.write('<a href="http://www.naslu.com/resource.aspx?id=150">Hash MD5 with Java</a>');
document.write('</p>');
document.write('<textarea name="code" id="code" class="java" rows="1" cols="1">');
document.write('public static String encryptMD5(String code){\n		try{			\n			MessageDigest md = MessageDigest.getInstance("MD5");			\n			byte[] input = code.getBytes(); //"UTF8");			\n			input=md.digest(input);			\n			code = toHexadecimal(input); //new String(input,"UTF8");\n			\n			return code;\n		}catch(Exception e){\n			\n			return code;\n		}\n		\n	}	\n	private static String toHexadecimal(byte[] datos) \n	{ \n            String resultado=""; \n            ByteArrayInputStream input = new ByteArrayInputStream(datos); \n            String cadAux; \n            boolean ult0=false;\n            int leido = input.read(); \n            while(leido != -1) \n            { \n                    cadAux = Integer.toHexString(leido); \n                    if(cadAux.length() < 2){ //Hay que aÒadir un 0 \n                            resultado += "0";\n                            if(cadAux.length() == 0)\n                            	ult0=true;\n                    }else{ ult0=false;}                    \n                    resultado += cadAux; \n                    leido = input.read(); \n            } \n            if(ult0)//quitamos el 0 si es un caracter aislado\n				resultado=\n			        	resultado.substring(0, resultado.length()-2)+resultado.charAt(resultado.length()-1);\n            return resultado; \n	}\n}');
document.write('</textarea>');
document.write('<script languaje="javascript" type="text/javascript">');
document.write('dp.SyntaxHighlighter.ClipboardSwf = \'http://www.naslu.com/flash/clipboard.swf\';dp.SyntaxHighlighter.HighlightAll("code");');
document.write('</script>');
document.write('<a href="http://www.naslu.com" style="font-family:Arial;font-size:9px;color:#444444;font-weight:bold;">Powered by naslu.com</a>');