List of usage examples for org.apache.commons.codec.binary Hex encodeHexString
public static String encodeHexString(byte[] data)
From source file:net.michaelpigg.xbeelib.protocol.impl.DefaultAtCommandResponseFormatter.java
public void formatTo(Formatter formatter, int flags, int width, int precision) { final StringBuilder sb = new StringBuilder(format("%s response: ", response.getCommand())); sb.append(format("Frame ID = %d;", response.getFrameId())) .append(format("Status = %s;", response.getStatus().toString())); final byte[] responseBytes = response.getResponse(); sb.append(format("Data: %s\n", Hex.encodeHexString(responseBytes))); sb.append("\n"); formatter.format(sb.toString());//from w w w . ja va 2 s. c om }
From source file:com.themodernway.common.util.SHA512Helper.java
@Override public String sha512(final CharSequence text) { return Hex.encodeHexString(DigestUtils.getSha512Digest().digest(text.toString().getBytes(Charsets.UTF_8))); }
From source file:com.digitalpebble.stormcrawler.aws.bolt.CloudSearchUtils.java
/** Returns a normalised doc ID based on the URL of a document **/ public static String getID(String url) { // the document needs an ID // see//w w w .j av a2 s . co m // http://docs.aws.amazon.com/cloudsearch/latest/developerguide/preparing-data.html#creating-document-batches // A unique ID for the document. A document ID can contain any // letter or number and the following characters: _ - = # ; : / ? @ // &. Document IDs must be at least 1 and no more than 128 // characters long. byte[] dig = digester.digest(url.getBytes(StandardCharsets.UTF_8)); String ID = Hex.encodeHexString(dig); // is that even possible? if (ID.length() > 128) { throw new RuntimeException("ID larger than max 128 chars"); } return ID; }
From source file:de.huxhorn.lilith.tools.CreateMd5Command.java
public static boolean createMd5(File input) { final Logger logger = LoggerFactory.getLogger(CreateMd5Command.class); if (!input.isFile()) { if (logger.isWarnEnabled()) logger.warn("{} isn't a file!", input.getAbsolutePath()); return false; }//from w w w . j a va2 s .c o m File output = new File(input.getParentFile(), input.getName() + ".md5"); try { FileInputStream fis = new FileInputStream(input); byte[] md5 = ApplicationPreferences.getMD5(fis); if (md5 == null) { if (logger.isWarnEnabled()) { logger.warn("Couldn't calculate checksum for {}!", input.getAbsolutePath()); } return false; } FileOutputStream fos = new FileOutputStream(output); fos.write(md5); fos.close(); if (logger.isInfoEnabled()) { logger.info("Wrote checksum of {} to {}.", input.getAbsolutePath(), output.getAbsolutePath()); logger.info("MD5: {}", Hex.encodeHexString(md5)); } } catch (IOException e) { if (logger.isWarnEnabled()) logger.warn("Exception while creating checksum!", e); return false; } return true; }
From source file:com.arrow.acn.client.utils.MD5Util.java
public static String calcMD5ChecksumString(String pathname) throws NoSuchAlgorithmException, IOException { return Hex.encodeHexString(calcMD5Checksum(pathname)); }
From source file:com.srotya.flow.collector.marauder.NetflowEvent.java
public void initHdrs() { super.initHdrs(); getHeaders().put("nv", String.valueOf(getSigID())); getHeaders().put("sa", Hex.encodeHexString(getSrcAddr())); getHeaders().put("da", Hex.encodeHexString(getDstAddr())); // getHeaders().put(IDS_EVENT_SRC_PRT, String.valueOf(getSrcPort())); // getHeaders().put(IDS_EVENT_DST_PORT, String.valueOf(getDstPort())); }
From source file:com.ai.smart.bottom.helper.MacUtils.java
public static String hmacsha256(String secret, String data) { Mac mac = null;/* w w w. j a va 2 s . c om*/ byte[] doFinal = null; try { mac = Mac.getInstance(HMAC_ALGORITHM); //??MD5 byte[] dataBytes = DigestUtils.md5(data); //sourcekeyMD5, SecretKey secretkey = new SecretKeySpec(DigestUtils.md5(secret), HMAC_ALGORITHM); mac.init(secretkey); //HmacSHA256 doFinal = mac.doFinal(dataBytes); } catch (NoSuchAlgorithmException e) { throw new RuntimeException(e); } catch (InvalidKeyException e) { } String checksum = Hex.encodeHexString(doFinal).toLowerCase(); return checksum; }
From source file:com.mnr.java.intellij.idea.plugin.base64helper.HexDecoderPopupItem.java
@Override public String encodeDecode(String selectedText) { return Hex.encodeHexString(Base64.decodeBase64(selectedText)).toUpperCase(); }
From source file:at.gv.egiz.pdfas.web.helper.DigestHelper.java
public static String getHexEncodedHash(byte[] data, String algorithm) throws NoSuchAlgorithmException { MessageDigest md = MessageDigest.getInstance(algorithm); byte[] hash = md.digest(data); return Hex.encodeHexString(hash); }
From source file:com.simplymeasured.hive.UDFSHA1Hash.java
public String evaluate(String valueToHash) { return Hex.encodeHexString(DigestUtils.sha(valueToHash)); }