List of usage examples for org.bouncycastle.util.encoders Hex toHexString
public static String toHexString(byte[] data, int off, int length)
From source file:org.ethereum.crypto.HashUtil.java
License:Open Source License
/** * @return generates random peer id for the HelloMessage */// www .j a va2s. c o m public static byte[] randomPeerId() { byte[] peerIdBytes = new BigInteger(512, Utils.getRandom()).toByteArray(); final String peerId; if (peerIdBytes.length > 64) { peerId = Hex.toHexString(peerIdBytes, 1, 64); } else { peerId = Hex.toHexString(peerIdBytes); } return Hex.decode(peerId); }
From source file:org.ethereum.net.NodeHandler.java
License:Open Source License
@Override public String toString() { return "NodeHandler[node: " + node.getHost() + ":" + node.getPort() + ", id=" + (node.getId().getID().length > 0 ? Hex.toHexString(node.getId().getID(), 0, 4) : "empty") + "]"; }
From source file:org.ethereum.util.Utils.java
License:Open Source License
/** * @param addr length should be 20//from w w w . ja v a 2s . c o m * @return short string represent 1f21c... */ public static String getAddressShortString(byte[] addr) { if (!isValidAddress(addr)) { throw new Error("not an address"); } String addrShort = Hex.toHexString(addr, 0, 3); StringBuffer sb = new StringBuffer(); sb.append(addrShort); sb.append("..."); return sb.toString(); }