Package java.security

Examples of java.security.MessageDigest.digest()


     */
    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

   protected String createHash(byte[] entity)
   {
      try
      {
         MessageDigest messagedigest = MessageDigest.getInstance("MD5");
         byte abyte0[] = messagedigest.digest(entity);
         return byteArrayToHexString(abyte0);
      }
      catch (NoSuchAlgorithmException e)
      {
         throw new RuntimeException(e);
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

   
    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

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

            if (includeDate) digest.update(NaturalOrder.encodeLong(file.lastModified(), 8), 0, 8);
        } finally {
            raf.close();
            try {raf.getChannel().close();} catch (final IOException e) {}
        }
        return digest.digest();
    }

    private static byte[] encodeMD5Raw(final byte[] b) {
        try {
            final MessageDigest digest = MessageDigest.getInstance("MD5");
View Full Code Here

            final byte[] buf = new byte[2048];
            int n;
            while ((n = in.read(buf)) > 0) digest.update(buf, 0, n);
            in.close();
            // now compute the hex-representation of the md5 digest
            return digest.digest();
        } catch (final java.security.NoSuchAlgorithmException e) {
            System.out.println("Internal Error at md5:" + e.getMessage());
        } catch (final java.io.IOException e) {
            System.out.println("byte[] error: " + e.getMessage());
        }
View Full Code Here

       
        try {
            MessageDigest md5 = MessageDigest.getInstance("MD5");
            md5.reset();
            md5.update(buf.array());
            return md5.digest();
        } catch (NoSuchAlgorithmException nse) {
            throw new IOException(nse.toString());
        }
    }
   
View Full Code Here

    MessageDigest md5 = getMd5Digest();
    md5.reset();
         md5.update(secretBytes);
         md5.update(randomBytes);
    return md5.digest();
  }
 
  /**
   * AccountingRequest overrides this
   * method to create a request authenticator as specified by RFC 2866.    
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.