Package java.security

Examples of java.security.MessageDigest.update()


    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);

    // now calculate the hash
    byte[] encodedPassword = md.digest();

    StringBuilder buf = new StringBuilder();
View Full Code Here


            constraints.insets = valueInsets;

            try
            {
                MessageDigest md = MessageDigest.getInstance("SHA1");
                md.update(certificate.getEncoded());
                String sha1String = getHex(md.digest());

                md = MessageDigest.getInstance("MD5");
                md.update(certificate.getEncoded());
                String md5String = getHex(md.digest());
View Full Code Here

                MessageDigest md = MessageDigest.getInstance("SHA1");
                md.update(certificate.getEncoded());
                String sha1String = getHex(md.digest());

                md = MessageDigest.getInstance("MD5");
                md.update(certificate.getEncoded());
                String md5String = getHex(md.digest());

                JTextArea sha1Area = new JTextArea(sha1String);
                sha1Area.setLineWrap(false);
                sha1Area.setOpaque(false);
View Full Code Here

      {
         MessageDigest digest = getDigest();
         try
         {
            // update
            digest.update(pathName.getBytes());
            // return
            return digest.digest();
         }
         finally
         {
View Full Code Here

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

            }
        }

        byte[] sha1hash = new byte[40];

        md.update(text.getBytes(), 0, text.length());

        sha1hash = md.digest();

        return convertToHex(sha1hash);
    }
View Full Code Here

  }

  private String encode(String plaintext) {
    try {
      MessageDigest md = MessageDigest.getInstance("MD5");
      md.update(plaintext.getBytes("UTF-8"));
      return Base64.encodeBytes(md.digest());
    } catch (NoSuchAlgorithmException e) {
      log.error(e.getMessage(), e);
    } catch (UnsupportedEncodingException e) {
      log.error(e.getMessage(), e);
View Full Code Here

        try {
            MessageDigest md = MessageDigest.getInstance("SHA");

            //Create the encrypted Byte[]
            md.update( password.getBytes() );
            byte[] hash = md.digest();

            //Convert the byte array into a String

            StringBuffer hashStringBuf = new StringBuffer();
View Full Code Here

  public static String hash(String string, String algorithm, String encoding) throws UnsupportedEncodingException{

    try {
      MessageDigest digest = MessageDigest.getInstance(algorithm);

      digest.update(string.getBytes(encoding));

      byte[] encodedPassword = digest.digest();

      return new BigInteger(1, encodedPassword).toString(16);
View Full Code Here

    try {
      MessageDigest digest = MessageDigest.getInstance(HashAlgorithms.SHA1);

      try {
        digest.update(string.getBytes("UTF-8"));

      } catch (UnsupportedEncodingException e) {

        throw new RuntimeException(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.