Package java.security

Examples of java.security.MessageDigest.update()


        throw new RuntimeException(e);
      }

      byte[] encodedPassword = digest.digest();

      digest.update(encodedPassword);

      encodedPassword = digest.digest();

      String hash = new BigInteger(1, encodedPassword).toString(16).toUpperCase();
View Full Code Here


        /* Append the MD5 hash of this resource name */
        try {
            MessageDigest digester = MessageDigest.getInstance("MD5");
            digester.reset();
            digester.update(path.getBytes("UTF8"));
            etag.append(DAVUtilities.toHexString(digester.digest()));
            etag.append('-');
        } catch (Exception e) {
            // If we can't get the MD5 HASH, let's ignore and hope...
        }
View Full Code Here

                URL url = new URL(sku);
                String host = url.getHost();
                if (host == null) throw new IOException("charding - bad url, host empty: " + sku);
                try {
                    MessageDigest digest = MessageDigest.getInstance("MD5");
                    digest.update(host.getBytes(charsetUTF8));
                    byte[] md5 = digest.digest();
                    return (0xff & md5[0]) % this.dimension;
                } catch (NoSuchAlgorithmException e) {
                    throw new IOException("charding - no md5 available: " + e.getMessage());
                }
View Full Code Here

     * @return hashed string
     */
    public static String digest(String string) throws NoSuchAlgorithmException, UnsupportedEncodingException {
        byte[] b = string.getBytes();
        MessageDigest md = MessageDigest.getInstance("MD5");
        md.update(b);
        byte[] digest = md.digest();
        return new String(digest);
    }

}
View Full Code Here

      {
         length = Integer.parseInt(attributes.get(LENGTH));
      }

      byte[] bodyHash = null;
      digest.update(body, 0, length);
      bodyHash = digest.digest();
      return bodyHash;
   }

   private void updateSignatureWithHeader(Map transmittedHeaders, Signature signature) throws SignatureException
View Full Code Here

    };

    public String hash(String text) {
        try {
            MessageDigest md = MessageDigest.getInstance(hashFunction);
            md.update(text.getBytes(charset));
            byte[] raw = md.digest();
            return new String(encodeHex(raw));
        }
        catch (Exception e) {
            throw new RuntimeException(e);
View Full Code Here

    String charset      = "UTF-8";
   
    public String hash(String password) {
        try {
            MessageDigest md = MessageDigest.getInstance(hashFunction);
            md.update(password.getBytes(charset));
            byte[] raw = md.digest();
            return new String(Hex.encodeHex(raw));
        }
        catch (Exception e) {
            throw new RuntimeException(e);       
View Full Code Here

      digest.reset();
      fromPool = false;
    }
        byte[] keyBytes;
        keyBytes = UTF8.getBytes(key);
        digest.update(keyBytes);
        final byte[] result = digest.digest();
        digest.reset();
        if (fromPool) {
            returntopool: while (true) {
                try {
View Full Code Here

        final RandomAccessFile raf = new RandomAccessFile(file, "r");
        final byte[] a = new byte[mb];
        try {
            raf.seek(0);
            raf.readFully(a, 0, mb);
            digest.update(a, 0, mb);
            raf.seek(fl - mb);
            raf.readFully(a, 0, mb);
            digest.update(a, 0, mb);
            digest.update(NaturalOrder.encodeLong(fl, 8), 0, 8);
            if (includeDate) digest.update(NaturalOrder.encodeLong(file.lastModified(), 8), 0, 8);
View Full Code Here

            raf.seek(0);
            raf.readFully(a, 0, mb);
            digest.update(a, 0, mb);
            raf.seek(fl - mb);
            raf.readFully(a, 0, mb);
            digest.update(a, 0, mb);
            digest.update(NaturalOrder.encodeLong(fl, 8), 0, 8);
            if (includeDate) digest.update(NaturalOrder.encodeLong(file.lastModified(), 8), 0, 8);
        } finally {
            raf.close();
            try {raf.getChannel().close();} catch (final IOException e) {}
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.