List of usage examples for org.apache.commons.codec.binary Hex encodeHexString
public static String encodeHexString(byte[] data)
From source file:com.github.horrorho.liquiddonkey.util.Bytes.java
public static String hex(byte[] bytes) { if (bytes == null) { return "null"; }/* w w w . java2 s . c o m*/ return Hex.encodeHexString(bytes).toLowerCase(Locale.US); }
From source file:gobblin.kafka.serialize.MD5Digest.java
/** * Static method to get an MD5Digest from a binary byte representation * @param md5Bytes/* w w w .j av a 2 s .c o m*/ * @return a filled out MD5Digest */ public static MD5Digest fromBytes(byte[] md5Bytes) { Preconditions.checkArgument(md5Bytes.length == MD5_BYTES_LENGTH, "md5 bytes must be " + MD5_BYTES_LENGTH + " bytes in length, found " + md5Bytes.length + " bytes."); String md5String = Hex.encodeHexString(md5Bytes); return new MD5Digest(md5String, md5Bytes); }
From source file:fr.cph.stock.security.SecurityServiceImpl.java
/** * Encode to sha256 the user password/*from w ww .ja va 2 s . com*/ * * @param str the password to encode * @return an encoded string * @throws NoSuchAlgorithmException the NoSuchAlgorithmException * @throws UnsupportedEncodingException the UnsupportedEncodingException */ @Override public String encodeToSha256(final String str) throws NoSuchAlgorithmException, UnsupportedEncodingException { final MessageDigest digest = MessageDigest.getInstance("SHA-256"); final byte[] hash = digest.digest(str.getBytes("UTF-8")); return Hex.encodeHexString(hash); }
From source file:eu.europa.ec.markt.dss.validation.CertificateRef.java
@Override public String toString() { return "CertificateRef[issuerName=" + issuerName + ",issuerSerial=" + issuerSerial + ",digest=" + Hex.encodeHexString(digestValue) + "]"; }
From source file:com.bitbreeds.webrtc.sctp.model.SCTPFixedAttribute.java
@Override public String toString() { return "SCTPFixedAttribute{" + "type=" + type + ", data=" + Hex.encodeHexString(data) + '}'; }
From source file:com.thoughtworks.go.util.CachedDigestUtils.java
private static String compute(final String string, String algorithm) { return objectPools.computeDigest(algorithm, digest -> { digest.update(org.apache.commons.codec.binary.StringUtils.getBytesUtf8(string)); return Hex.encodeHexString(digest.digest()); });//from w w w. j av a 2 s .c o m }
From source file:com.bitbreeds.webrtc.signaling.CertUtil.java
/** * * @param fingerPrint sha256 of an encoded cert * @return String description of fingerprint formatted 'sha-256 AB:CD...' *//*w ww .j av a 2 s. com*/ public static String createFingerprintString(byte[] fingerPrint) { StringBuilder bldr = new StringBuilder(); bldr.append("sha-256 "); for (int i = 0; i < fingerPrint.length; i++) { String a = Hex.encodeHexString(new byte[] { fingerPrint[i] }); bldr.append(a.toUpperCase()); if (i != fingerPrint.length - 1) { bldr.append(":"); } } return bldr.toString(); }
From source file:com.bitbreeds.webrtc.signaling.BindingService.java
public byte[] processBindingRequest(byte[] data, String userName, String password, InetSocketAddress sender) { logger.trace("Input: " + Hex.encodeHexString(data)); StunMessage msg = StunMessage.fromBytes(data); logger.trace("InputParsed: " + msg); byte[] content = SignalUtil.joinBytesArrays(SignalUtil.twoBytesFromInt(0x01), SignalUtil.xor(SignalUtil.twoBytesFromInt(sender.getPort()), Arrays.copyOf(msg.getHeader().getCookie(), 2)), SignalUtil.xor(sender.getAddress().getAddress(), msg.getHeader().getCookie())); StunAttribute attr = new StunAttribute(StunAttributeTypeEnum.XOR_MAPPED_ADDRESS, content); StunAttribute user = msg.getAttributeSet().get(StunAttributeTypeEnum.USERNAME); String strUser = new String(user.toBytes()).split(":")[0].trim(); msg.validate(password, data);/* www . j av a2 s.c om*/ HashMap<StunAttributeTypeEnum, StunAttribute> outSet = new HashMap<>(); outSet.put(StunAttributeTypeEnum.XOR_MAPPED_ADDRESS, attr); outSet.putAll(msg.getAttributeSet()); StunMessage output = StunMessage.fromData(StunRequestTypeEnum.BINDING_RESPONSE, msg.getHeader().getCookie(), msg.getHeader().getTransactionID(), outSet, true, true, strUser, password); byte[] bt = output.toBytes(); logger.trace("Response: " + Hex.encodeHexString(bt)); return bt; }
From source file:com.github.horrorho.inflatabledonkey.data.blob.BlobA6.java
@Override public String toString() { return "BlobA6{" + "type=0x" + Integer.toHexString(type()) + ",length=0x" + Integer.toHexString(length()) + ", x=" + x + ", tag=0x" + Hex.encodeHexString(tag) + ", m2=0x" + Hex.encodeHexString(m2()) + ", iv=0x" + Hex.encodeHexString(iv()) + ", data=0x" + Hex.encodeHexString(data()) + '}'; }
From source file:management.limbr.data.model.util.EntityUtil.java
public String generatePasswordHash(String userid, String password) { try {//from ww w. j a v a2s . co m MessageDigest md5 = MessageDigest.getInstance("MD5"); md5.update(userid.getBytes()); md5.update(SALT.getBytes()); md5.update(password.getBytes()); byte[] digest = md5.digest(); return Hex.encodeHexString(digest); } catch (NoSuchAlgorithmException ex) { throw new IllegalStateException("Could not load MD5 for hashing passwords", ex); } }