/** * Produces a raw checksum for the given input data. Currently uses a message digest * * @param data * @return The checksum. */ public static String rawChecksum(byte[] data) { return new String(getMessageDigest().digest(Preconditions.checkNotNull(data))); }
/** * Produces a raw checksum for the given input data. Currently uses a message digest * * @param data * @return The checksum. */ public static String rawChecksum(byte[] data) { return new String(getMessageDigest().digest(Preconditions.checkNotNull(data))); }
/** * Produces a raw checksum for the given input data. Currently uses a message digest * * @param data * @return The checksum. */ public static String rawChecksum(byte[] data) { return new String(getMessageDigest().digest(Preconditions.checkNotNull(data))); }
/** * Produces a raw checksum for the given input data. Currently uses a message digest * * @param data * @return The checksum. */ public static String rawChecksum(byte[] data) { return new String(getMessageDigest().digest(Preconditions.checkNotNull(data))); }
/** * Produces a raw checksum for the given input data. Currently uses a message digest * * @param data * @return The checksum. */ public static String rawChecksum(byte[] data) { return new String(getMessageDigest().digest(Preconditions.checkNotNull(data))); }
/** * Produces a checksum for the given input data. Currently uses a hexified * message digest. * * @param data * @return The checksum. */ public static String checksum(byte[] data) { byte[] hashBytes = getMessageDigest().digest(Preconditions.checkNotNull(data)); return bytesToHex(hashBytes); }
/** * Produces a checksum for the given input data. Currently uses a hexified * message digest. * * @param data * @return The checksum. */ public static String checksum(byte[] data) { byte[] hashBytes = getMessageDigest().digest(Preconditions.checkNotNull(data)); char[] hex = new char[2 * hashBytes.length]; // Convert to hex. possibly change to base64 in the future for smaller // signatures. int offset = 0; for (byte b : hashBytes) { hex[offset++] = HEX_CHARS[(b & 0xF0) >>> 4]; // upper 4 bits hex[offset++] = HEX_CHARS[(b & 0x0F)]; // lower 4 bits } return new String(hex); }
/** * Produces a checksum for the given input data. Currently uses a hexified * message digest. * * @param data * @return The checksum. */ public static String checksum(byte[] data) { byte[] hashBytes = getMessageDigest().digest(Preconditions.checkNotNull(data)); char[] hex = new char[2 * hashBytes.length]; // Convert to hex. possibly change to base64 in the future for smaller // signatures. int offset = 0; for (byte b : hashBytes) { hex[offset++] = HEX_CHARS[(b & 0xF0) >>> 4]; // upper 4 bits hex[offset++] = HEX_CHARS[(b & 0x0F)]; // lower 4 bits } return new String(hex); }
/** * Produces a checksum for the given input data. Currently uses a hexified * message digest. * * @param data * @return The checksum. */ public static String checksum(byte[] data) { byte[] hashBytes = getMessageDigest().digest(Preconditions.checkNotNull(data)); return bytesToHex(hashBytes); }
private void ensureDigestObjectExists() { if (digest == null) { digest = HashUtil.getMessageDigest(); digest.update(buffer.toByteArray()); } } }
/** * Produces a checksum for the given input data. Currently uses a hexified * message digest. * * @param data * @return The checksum. */ public static String checksum(byte[] data) { byte[] hashBytes = getMessageDigest().digest(Preconditions.checkNotNull(data)); return bytesToHex(hashBytes); }
@Inject public AllJsIframeVersioner(FeatureRegistry registry) { String charset = Charset.defaultCharset().name(); MessageDigest digest = HashUtil.getMessageDigest(); digest.reset(); for (FeatureResource resource : registry.getAllFeatures().getResources()) { // Emulate StringBuilder append of content update(digest, resource.getContent(), charset); update(digest, resource.getDebugContent(), charset); } allJsChecksum = HashUtil.bytesToHex(digest.digest()); }
@Before public void setUp() { String featureContent = "THE_FEATURE_CONTENT"; String debugContent = "FEATURE_DEBUG_CONTENT"; String charset = Charset.defaultCharset().name(); MessageDigest digest = HashUtil.getMessageDigest(); try{ digest.update(featureContent.getBytes(charset)); } catch (UnsupportedEncodingException e) { digest.update(featureContent.getBytes()); } try{ digest.update(debugContent.getBytes(charset)); } catch (UnsupportedEncodingException e) { digest.update(debugContent.getBytes()); } featureChecksum = HashUtil.bytesToHex(digest.digest()); FeatureRegistry registry = createMock(FeatureRegistry.class); FeatureResource resource = new FeatureResource.Simple(featureContent, debugContent, "js"); List<FeatureResource> allResources = Lists.newArrayList(resource); final FeatureRegistry.LookupResult lr = createMock(FeatureRegistry.LookupResult.class); expect(lr.getResources()).andReturn(allResources); replay(lr); expect(registry.getAllFeatures()).andReturn(lr).once(); replay(registry); versioner = new AllJsIframeVersioner(registry); verify(registry); }
@Before public void setUp() { String featureContent = "THE_FEATURE_CONTENT"; String debugContent = "FEATURE_DEBUG_CONTENT"; String charset = Charset.defaultCharset().name(); MessageDigest digest = HashUtil.getMessageDigest(); try{ digest.update(featureContent.getBytes(charset)); } catch (UnsupportedEncodingException e) { digest.update(featureContent.getBytes()); } try{ digest.update(debugContent.getBytes(charset)); } catch (UnsupportedEncodingException e) { digest.update(debugContent.getBytes()); } featureChecksum = HashUtil.bytesToHex(digest.digest()); FeatureRegistry registry = createMock(FeatureRegistry.class); FeatureResource resource = new FeatureResource.Simple(featureContent, debugContent, "js"); List<FeatureResource> allResources = Lists.newArrayList(resource); final FeatureRegistry.LookupResult lr = createMock(FeatureRegistry.LookupResult.class); expect(lr.getResources()).andReturn(allResources); replay(lr); expect(registry.getAllFeatures()).andReturn(lr).once(); replay(registry); versioner = new AllJsIframeVersioner(registry); verify(registry); }