/** * This will take this string and create a hex representation of the bytes that make the string. * * @return A hex string representing the bytes in this string. */ public String toHexString() { return Hex.getString(bytes); }
/** * Gets the SHA-1-Hash has of given byte[]-content. * * @param content to be hashed * @return SHA-1 hash String */ protected static String getSha1Hash(byte[] content) { try { MessageDigest md = MessageDigest.getInstance("SHA-1"); return Hex.getString(md.digest(content)); } catch (NoSuchAlgorithmException e) { LOG.error("No SHA-1 Algorithm found", e); } return null; }
/** * Go through the elements of a COSArray containing each an COSStream to print in Hex. * * @param elements COSArray of elements containing a COS Stream * @param description to append on Print * @throws IOException */ private void printStreamsFromArray(COSArray elements, String description) throws IOException { for (COSBase baseElem : elements) { COSObject streamObj = (COSObject) baseElem; if (streamObj.getObject() instanceof COSStream) { COSStream cosStream = (COSStream) streamObj.getObject(); try (InputStream is = cosStream.createInputStream()) { byte[] streamBytes = IOUtils.toByteArray(is); System.out.println(description + " (" + elements.indexOf(streamObj) + "): " + Hex.getString(streamBytes)); } } } }
/** * This will take this string and create a hex representation of the bytes that make the string. * * @return A hex string representing the bytes in this string. */ public String toHexString() { return Hex.getString(bytes); }
String signatureHashHex = Hex.getString(signatureHash);
String signatureHashHex = Hex.getString(signatureHash);
/** * This will take this string and create a hex representation of the bytes that make the string. * * @return A hex string representing the bytes in this string. */ public String toHexString() { return Hex.getString(bytes); }
/** * Gets the SHA-1-Hash has of given byte[]-content. * * @param content to be hashed * @return SHA-1 hash String */ protected static String getSha1Hash(byte[] content) { try { MessageDigest md = MessageDigest.getInstance("SHA-1"); return Hex.getString(md.digest(content)); } catch (NoSuchAlgorithmException e) { LOG.error("No SHA-1 Algorithm found", e); } return null; }
/** * Go through the elements of a COSArray containing each an COSStream to print in Hex. * * @param elements COSArray of elements containing a COS Stream * @param description to append on Print * @throws IOException */ private void printStreamsFromArray(COSArray elements, String description) throws IOException { for (COSBase baseElem : elements) { COSObject streamObj = (COSObject) baseElem; if (streamObj.getObject() instanceof COSStream) { COSStream cosStream = (COSStream) streamObj.getObject(); COSInputStream input = cosStream.createInputStream(); byte[] streamBytes = IOUtils.toByteArray(input); System.out.println(description + " (" + elements.indexOf(streamObj) + "): " + Hex.getString(streamBytes)); } } }