Package java.security

Examples of java.security.MessageDigest.digest()


    }

    public static String MD5(String toEncode) throws NoSuchAlgorithmException, UnsupportedEncodingException {
        MessageDigest digest = MessageDigest.getInstance("MD5");
        digest.update(toEncode.getBytes("ISO-8859-1"));
        return ByteUtils.toHex(digest.digest());
    }

}
View Full Code Here


        Long serialVersionUID = new Long(0L);
        try
        {
            MessageDigest md = MessageDigest.getInstance("SHA");
            byte[] hashBytes = md.digest(signature.getBytes());

            long hash = 0;
            for (int ctr = Math.min(hashBytes.length, 8) - 1; ctr >= 0; ctr--)
            {
                hash = (hash << 8) | (hashBytes[ctr] & 0xFF);
View Full Code Here

        Long serialVersionUID = new Long(0L);
        try
        {
            MessageDigest md = MessageDigest.getInstance("SHA");
            byte[] hashBytes = md.digest(signature.getBytes());

            long hash = 0;
            for (int ctr = Math.min(hashBytes.length, 8) - 1; ctr >= 0; ctr--)
            {
                hash = (hash << 8) | (hashBytes[ctr] & 0xFF);
View Full Code Here

        String serialVersionUID = String.valueOf(0L);
        try
        {
            MessageDigest md = MessageDigest.getInstance("SHA");
            byte[] hashBytes = md.digest(signature.getBytes());

            long hash = 0;
            for (int ctr = Math.min(
                        hashBytes.length,
                        8) - 1; ctr >= 0; ctr--)
View Full Code Here

  public static String MD5(String str) {
    try {
      MessageDigest md = MessageDigest.getInstance("MD5");
      md.update(str.getBytes());
      return hexStringFromBytes(md.digest());
    } catch (Exception e) {
      e.printStackTrace();
      return "";
    }
  }
View Full Code Here

  public static String MD5(byte[] source) {
    try {
      MessageDigest md = MessageDigest.getInstance("MD5");
      md.update(source);
      return hexStringFromBytes(md.digest());
    } catch (Exception e) {
      e.printStackTrace();
      return "";
    }
  }
View Full Code Here

  public static byte[] MD5bytes(String str) {
    try {
      MessageDigest md = MessageDigest.getInstance("MD5");
      md.update(str.getBytes());
      return md.digest();
    } catch (Exception e) {
      e.printStackTrace();
      return null;
    }
  }
View Full Code Here

                DigestInputStream in = new DigestInputStream(url.openStream(), md);
                try {
                    byte[] buf = new byte[8192];
                    int n;
                    do { n = in.read(buf); } while (n > 0);
                    digest = md.digest();
                } finally {
                    in.close();
                }
                StringBuilder sb = new StringBuilder();
                for (byte b: digest)
View Full Code Here

      md2.update(buf2);
    }

    ins.close();
    ind.close();
    return MessageDigest.isEqual(md1.digest(), md2.digest());
  }
}
View Full Code Here

    catch (NoSuchAlgorithmException ex){
      fLogger.severe("Cannot find SHA-1 hash function.");
    }

    if (sha != null){
      byte[] digest =  sha.digest( aCleartext.getBytes() );
      result = hexEncode(digest);
    }
    else {
      result = aCleartext;
    }
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.