Here you can find the source of toHex(String string)
public static String toHex(String string)
//package com.java2s; /*//from w w w . j a v a 2 s. co m * Copyright (c) 2006-2012 Nuxeo SA (http://nuxeo.com/) and others. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Nuxeo - initial API and implementation * * $Id: StringUtils.java 28482 2008-01-04 15:33:39Z sfermigier $ */ public class Main { public static String toHex(String string) { char[] chars = string.toCharArray(); StringBuilder buf = new StringBuilder(); for (char c : chars) { buf.append(Integer.toHexString(c).toUpperCase()); } return buf.toString(); } }