Here you can find the source of bytesToHexString(byte[] mpi)
static String bytesToHexString(byte[] mpi)
//package com.java2s; /*/* w w w. j a v a2s . com*/ * Java OTR library * Copyright (C) 2008-2009 Ian Goldberg, Muhaimeen Ashraf, Andrew Chung, * Can Tang * * This library is free software; you can redistribute it and/or * modify it under the terms of version 2.1 of the GNU Lesser General * Public License as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ public class Main { static String bytesToHexString(byte[] mpi) { byte[] hex = new byte[2 * mpi.length]; for (int i = 0; i < mpi.length; i++) { int num = (int) (mpi[i] >> 4 & 0xf); if (num <= 9) { hex[2 * i] = (byte) ('0' + num); } else { hex[2 * i] = (byte) ('A' + num - 10); } num = (int) (mpi[i] & 0xf); if (num <= 9) { hex[2 * i + 1] = (byte) ('0' + num); } else { hex[2 * i + 1] = (byte) ('A' + num - 10); } } return new String(hex); } }