Package java.security

Examples of java.security.MessageDigest.update()


        try {
            messageDigest = MessageDigest.getInstance("MD5");
        } catch (NoSuchAlgorithmException e) {
            throw UncheckedException.asUncheckedException(e);
        }
        messageDigest.update(scriptText.getBytes());
        return new BigInteger(1, messageDigest.digest()).toString(16);
    }

    public static byte[] createHash(File file) {
        MessageDigest messageDigest;
View Full Code Here


                while (true) {
                    int nread = instr.read(buffer);
                    if (nread < 0) {
                        break;
                    }
                    messageDigest.update(buffer, 0, nread);
                }
            } finally {
                instr.close();
            }
        } catch (IOException e) {
View Full Code Here

        return s;
    }

    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

      '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };

  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

    {
      r = ins.read(buf1);
      ind.read(buf2);

      md1.update(buf1);
      md2.update(buf2);
    }

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

                    MessageDigest md = MessageDigest.getInstance( "MD5" );
                    int data;
                    while ( ( data = is.read() ) >= 0 )
                    {
                        jarSize++;
                        md.update( (byte)( data & 0xff ) );
                    }
                    m_outDebug.println( getRes().getString( "    Size: {0}", new Integer( jarSize ) ) );
                   
                    byte[] bytes = md.digest();
                    StringBuffer sb = new StringBuffer();
View Full Code Here

  StringBuffer out = new StringBuffer();
  try
  {
   //*-- create a message digest instance and compute the hash byte array
   MessageDigest md = MessageDigest.getInstance("SHA-1");
   md.reset(); md.update(in.getBytes());
   byte[] hash = md.digest();

   //*--- Convert the hash byte array to hexadecimal format, pad hex chars with leading zeroes
   //*--- to get a signature of consistent length (40) for all strings.
   for (int i = 0; i < hash.length; i++)
View Full Code Here

                BufferedInputStream bis = new BufferedInputStream(new FileInputStream(fFile));
                byte[] buff = new byte[1024];
                int chunk = 1024;
                int bytesRead = 0;
                while ((bytesRead = bis.read(buff, 0, chunk)) != -1) {
                    md.update(buff, 0, bytesRead);
                }
                digest = md.digest();
                String hexChar = null;
                if (digest != null) {
                    for (int i = 0; i < digest.length; i++) {
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.