@Override protected String getDigest(String value) { return Hashing.crc32().hashString(value, StandardCharsets.UTF_8).toString(); }
hf = Hashing.crc32(); break;
protected CRC32ChecksumProviderImpl() { super(Hashing.crc32()); }
/** * Computes the hashcode of the cached file. * * @return the hash code */ @Nullable private HashCode hashFile() { try { return Files.hash(mFile, Hashing.crc32()); } catch (IOException e) { return null; } }
@Override public ToStringHelper string() { ToStringHelper toString = super.string(); if (groupNames.size() != 0) toString.add("groupNames", groupNames); if (noKeyPair) toString.add("noKeyPair", noKeyPair); toString.add("keyPair", keyPair); if (userData != null && userData.size() > 0) toString.add("userDataCksum", Hashing.crc32().hashBytes(Bytes.toArray(userData))); ImmutableSet<BlockDeviceMapping> mappings = blockDeviceMappings.build(); if (mappings.size() != 0) toString.add("blockDeviceMappings", mappings); return toString; }
@Override public ToStringHelper string() { ToStringHelper toString = super.string(); if (groupNames.size() != 0) toString.add("groupNames", groupNames); if (noKeyPair) toString.add("noKeyPair", noKeyPair); toString.add("keyPair", keyPair); if (userData != null && userData.size() > 0) toString.add("userDataCksum", Hashing.crc32().hashBytes(Bytes.toArray(userData))); ImmutableSet<BlockDeviceMapping> mappings = blockDeviceMappings.build(); if (mappings.size() != 0) toString.add("blockDeviceMappings", mappings); return toString; }
@Override public ToStringHelper string() { ToStringHelper toString = super.string(); if (!groupNames.isEmpty()) toString.add("groupNames", groupNames); if (noKeyPair) toString.add("noKeyPair", noKeyPair); toString.add("keyPair", keyPair); if (userData != null && !userData.isEmpty()) toString.add("userDataCksum", Hashing.crc32().hashBytes(Bytes.toArray(userData))); ImmutableSet<BlockDeviceMapping> mappings = blockDeviceMappings.build(); if (!mappings.isEmpty()) toString.add("blockDeviceMappings", mappings); if (maxCount != null && maxCount.intValue() > 0) toString.add("maxCount", maxCount); if (clientToken != null) toString.add("clientToken", clientToken); return toString; }
@Override public ToStringHelper string() { ToStringHelper toString = super.string(); if (!groupNames.isEmpty()) toString.add("groupNames", groupNames); if (noKeyPair) toString.add("noKeyPair", noKeyPair); toString.add("keyPair", keyPair); if (userData != null && !userData.isEmpty()) toString.add("userDataCksum", Hashing.crc32().hashBytes(Bytes.toArray(userData))); ImmutableSet<BlockDeviceMapping> mappings = blockDeviceMappings.build(); if (!mappings.isEmpty()) toString.add("blockDeviceMappings", mappings); if (maxCount != null && maxCount.intValue() > 0) toString.add("maxCount", maxCount); if (clientToken != null) toString.add("clientToken", clientToken); return toString; }
private String createFingerprint(Class<?> contextClass, String resourceName) throws IOException { byte[] bytes = contextClass != null ? ResourceUtils.getBytes(contextClass, resourceName) : ResourceUtils.getBytes(resourceName); HashCode crc32 = Hashing.crc32().hashBytes(bytes); return Base64.getUrlEncoder().withoutPadding().encodeToString(crc32.asBytes()); } }
public static long computeFileChecksum(@Nonnull final File file, @Nonnull final Checksum checksum) throws IOException { return ByteStreams.hash(com.google.common.io.Files.newInputStreamSupplier(file), Hashing.crc32()) .padToLong(); }
private String createFingerprint(Class<?> contextClass, String resourceName) throws IOException { byte[] bytes = contextClass != null ? ResourceUtils.getBytes(contextClass, resourceName) : ResourceUtils.getBytes(resourceName); HashCode crc32 = Hashing.crc32().hashBytes(bytes); return BaseEncoding.base64Url().omitPadding().encode(crc32.asBytes()); } }
/** * FIXME why is this a long when crc32 returns an int? * @return a checksum of the graph, for use in verifying whether it changed or remained the same after * some operation. */ public long checksum () { LOG.info("Calculating transport network checksum..."); try { File tempFile = File.createTempFile("r5-network-checksum-", ".dat"); tempFile.deleteOnExit(); KryoNetworkSerializer.write(this, tempFile); HashCode crc32 = Files.hash(tempFile, Hashing.crc32()); tempFile.delete(); LOG.info("Network CRC is {}", crc32.hashCode()); return crc32.hashCode(); } catch (IOException e) { throw new RuntimeException(); } }
private String createFingerprint(String themeUri) throws IOException, MolgenisStyleException { String fileName = extractThemeNameFromThemeUri(themeUri); BootstrapVersion version = extractBootstrapVersionFromPath(themeUri); FileSystemResource styleData = styleService.getThemeData(fileName, version); byte[] bytes = IOUtils.toByteArray(styleData.getInputStream()); HashCode crc32 = Hashing.crc32().hashBytes(bytes); return BaseEncoding.base64Url().omitPadding().encode(crc32.asBytes()); }
private byte runHashFunction(int reps, HashFunction hashFunction) { byte result = 0x01; // Trick the JVM to prevent it from using the hash function non-polymorphically result ^= Hashing.crc32().hashInt(reps).asBytes()[0]; result ^= Hashing.adler32().hashInt(reps).asBytes()[0]; for (int i = 0; i < reps; i++) { result ^= hashFunction.hashBytes(testBytes).asBytes()[0]; } return result; } }
private static void configureStoredEntry(JarEntry entry, File inputFile) throws IOException { ByteSource byteSource = Files.asByteSource(inputFile); long size = inputFile.length(); entry.setMethod(ZipEntry.STORED); entry.setSize(size); entry.setCompressedSize(size); entry.setCrc(byteSource.hash(Hashing.crc32()).padToLong()); }
@Benchmark byte crc32HashFunction(int reps) { return runHashFunction(reps, Hashing.crc32()); }
/** * Default constructor. * * @throws PulsarServerException */ public NamespaceService(PulsarService pulsar) { this.pulsar = pulsar; host = pulsar.getAdvertisedAddress(); this.config = pulsar.getConfiguration(); this.loadManager = pulsar.getLoadManager(); ServiceUnitZkUtils.initZK(pulsar.getLocalZkCache().getZooKeeper(), pulsar.getBrokerServiceUrl()); this.bundleFactory = new NamespaceBundleFactory(pulsar, Hashing.crc32()); this.ownershipCache = new OwnershipCache(pulsar, bundleFactory); }
/** * Default constructor. * * @throws PulsarServerException */ public NamespaceService(PulsarService pulsar) { this.pulsar = pulsar; host = pulsar.getAdvertisedAddress(); this.config = pulsar.getConfiguration(); this.loadManager = pulsar.getLoadManager(); ServiceUnitZkUtils.initZK(pulsar.getLocalZkCache().getZooKeeper(), pulsar.getBrokerServiceUrl()); this.bundleFactory = new NamespaceBundleFactory(pulsar, Hashing.crc32()); this.ownershipCache = new OwnershipCache(pulsar, bundleFactory); this.namespaceClients = new ConcurrentOpenHashMap<>(); }