Package java.security

Examples of java.security.MessageDigest.reset()


    } catch (Exception e) {
      logger.error("Exception:{}", e);
      return password;
    }

    md.reset();

    // call the update method one or more times
    // (useful when you don't know the size of your data, eg. stream)
    md.update(unencodedPassword);
View Full Code Here


            return digest.digest();
         }
         finally
         {
            // reset
            digest.reset();
         }
      }

      public static MessageDigest getDigest() throws NoSuchAlgorithmException
      {
View Full Code Here

   * Creates a md5 encoded in base64 for given input.
   */
  public static String md5(byte[] input) {
    try {
      MessageDigest md5 = MessageDigest.getInstance("MD5");
      md5.reset();
      md5.update(input);
      return jfix.util.Base64.encodeBytes(md5.digest());
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
View Full Code Here

        etag.append('"');

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

      if (digestPool.size() == 0) {
          // if there are no digest objects left, create some on the fly
          // this is not the most effective way but if we wouldn't do that the encoder would block
          try {
                digest = MessageDigest.getInstance("MD5");
                digest.reset();
                fromPool = false;
            } catch (final NoSuchAlgorithmException e) {
            }
      }
        if (digest == null) try {
View Full Code Here

          try {
        digest = MessageDigest.getInstance("MD5");
      } catch (final NoSuchAlgorithmException e1) {
          Log.logException(e1);
      }
      digest.reset();
      fromPool = false;
    }
        byte[] keyBytes;
        keyBytes = UTF8.getBytes(key);
        digest.update(keyBytes);
View Full Code Here

    }
        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);
                    break returntopool;
View Full Code Here

    }

    private static byte[] encodeMD5Raw(final byte[] b) {
        try {
            final MessageDigest digest = MessageDigest.getInstance("MD5");
            digest.reset();
            final InputStream  in = new ByteArrayInputStream(b);
            final byte[] buf = new byte[2048];
            int n;
            while ((n = in.read(buf)) > 0) digest.update(buf, 0, n);
            in.close();
View Full Code Here

        buf.putLong(num);
        buf.flip();
       
        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

    byte[] secretBytes = RadiusUtil.getUtf8Bytes(sharedSecret);
    byte[] randomBytes = new byte[16];
    random.nextBytes(randomBytes);     

    MessageDigest md5 = getMd5Digest();
    md5.reset();
         md5.update(secretBytes);
         md5.update(randomBytes);
    return md5.digest();
  }
 
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.