Package com.google.common.hash

Examples of com.google.common.hash.HashCode$BytesHashCode


  public void addHash( long hash) {
    addHashItem( hash, Long.toString( hash));
  }
 
  public void addItem( String str) {
    HashCode hc = HASH.hashUnencodedChars( str);
    this.addHashItem( hc.asLong(), str);
  }
View Full Code Here


public class HashMD5UDF extends UDF {
  private HashFunction hash = Hashing.md5();


  public Long evaluate( String str) {
    HashCode hc = hash.hashUnencodedChars( str);

    return hc.asLong();
  }
View Full Code Here

                        @Override
                        public long getValue() {
                            throw new UnsupportedOperationException();
                        }
                    }));
            HashCode hash = hasher.hash();

            // wrap into AbstractBlob for the SHA-256 memorization feature
            if (!(blob instanceof AbstractBlob)) {
                final Blob b = blob;
                blob = new AbstractBlob(hash) {
                    @Override
                    public long length() {
                        return b.length();
                    }
                    @Override
                    public InputStream getNewStream() {
                        return b.getNewStream();
                    }
                };
            }

            String id = hash.toString();
            blobs.put(id, blob);
            return id;
        } catch (IOException e) {
            throw new MicroKernelException("Failed to create a blob", e);
        }
View Full Code Here

                        @Override
                        public long getValue() {
                            throw new UnsupportedOperationException();
                        }
                    }));
            HashCode hash = hasher.hash();

            // wrap into AbstractBlob for the SHA-256 memorization feature
            if (!(blob instanceof AbstractBlob)) {
                final Blob b = blob;
                blob = new AbstractBlob(hash) {
                    @Override
                    public long length() {
                        return b.length();
                    }
                    @Override
                    public InputStream getNewStream() {
                        return b.getNewStream();
                    }
                };
            }

            String id = hash.toString();
            blobs.put(id, blob);
            return id;
        } catch (IOException e) {
            throw new MicroKernelException("Failed to create a blob", e);
        }
View Full Code Here

     * @return the hash or null if an error happened
     */
    @Nullable
    private static String getFileHash(@NonNull File file) {
        try {
            HashCode hashCode = Files.hash(file, Hashing.sha1());
            return hashCode.toString();
        } catch (IOException ignored) {

        }

        return null;
View Full Code Here

            final int seed = randomInt();
            final int offset = randomInt(20);
            final int len = randomInt(randomBoolean() ? 20 : 200);
            final byte[] bytes = new byte[len + offset + randomInt(3)];
            getRandom().nextBytes(bytes);
            HashCode h1 = Hashing.murmur3_128(seed).hashBytes(bytes, offset, len);
            MurmurHash3.Hash128 h2 = MurmurHash3.hash128(bytes, offset, len, seed, new MurmurHash3.Hash128());
            assertEquals(h1, h2);
        }
    }
View Full Code Here

        return ((Regressor) model).regress(features);
    }

    private static Model getOrLoadModel(Slice slice)
    {
        HashCode modelHash = ModelUtils.modelHash(slice);

        Model model = MODEL_CACHE.getIfPresent(modelHash);
        if (model == null) {
            model = ModelUtils.deserialize(slice);
            MODEL_CACHE.put(modelHash, model);
View Full Code Here

     */
    static String getSha1(File f) throws Sha1Exception {
        synchronized (sBuffer) {

            try {
                HashCode value = ByteStreams.hash(Files.newInputStreamSupplier(f), Hashing.sha1());
                return value.toString();
            } catch (Exception e) {
                throw new Sha1Exception(f, e);
            }
        }
    }
View Full Code Here

            final Person customer = (Person) request.getSession().getAttribute("customer");
            PasswordGenerator generator = Generator.newPasswordGenerator(8, true, true, true, true);
            try {
                final String password = generator.generate();
                HashFunction hf = Hashing.sha1();
                HashCode hc = hf.newHasher()
                    .putString(password)
                    .hash();
                customer.setPassword(hc.toString());
                customer.addAccount(account);
                customerService.processCustomer(customer, password);
                response.sendRedirect(getServletContext().getContextPath() +
                            String.format("/auth/admin/customer?id=%d", customer.getId()));
            } catch (GenerationException ex) {
View Full Code Here

            throws ServletException, IOException {
        final String email = request.getParameter("mail");
        final String password = request.getParameter("password");
       
        HashFunction hf = Hashing.sha1();
        HashCode hc = hf.newHasher()
                .putString(password)
                .hash();
       
        final String hashedPassword = hc.toString();
      
       
        final Person p = personDao.findUserByMail(email);
        if (p == null) {
            doGet(request, response);
View Full Code Here

TOP

Related Classes of com.google.common.hash.HashCode$BytesHashCode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.