Package java.security

Examples of java.security.MessageDigest.digest()


                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);
                sha1Area.setWrapStyleWord(true);
View Full Code Here


   */
  private static byte[] digest(String type, byte[] bytes)
  {
        try {
         MessageDigest dist = MessageDigest.getInstance(type);
        return dist.digest(bytes);
        } catch (NoSuchAlgorithmException e) {
        throw new IllegalArgumentException("Cannot find digest:"+type, e);
        }
  }
 
View Full Code Here

         try
         {
            // update
            digest.update(pathName.getBytes());
            // return
            return digest.digest();
         }
         finally
         {
            // reset
            digest.reset();
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

   */
  public static String encrypt(String s) {
    byte[] inbytes = s.getBytes();
    try {
      MessageDigest md5Helper = MessageDigest.getInstance(HASH_ALGORITHM);
      byte[] outbytes = md5Helper.digest(inbytes);
      String out = md5Encoder.encode(outbytes);
      return out;
    } catch (NoSuchAlgorithmException e) {
      throw new AssertException("Cannot load MD5 Message Digest ," + HASH_ALGORITHM + " not supported");
    }
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

         log.trace("H(N) xor H(g): "+CryptoUtil.tob64(hxg));
      clientHash.update(hxg);
      if( log.isTraceEnabled() )
      {
         MessageDigest tmp = CryptoUtil.copy(clientHash);
         log.trace("H[H(N) xor H(g)]: "+CryptoUtil.tob64(tmp.digest()));
      }
      // clientHash = H(N) xor H(g) | H(U)
      clientHash.update(CryptoUtil.newDigest().digest(username.getBytes()));
      if( log.isTraceEnabled() )
      {
View Full Code Here

      // clientHash = H(N) xor H(g) | H(U)
      clientHash.update(CryptoUtil.newDigest().digest(username.getBytes()));
      if( log.isTraceEnabled() )
      {
         MessageDigest tmp = CryptoUtil.copy(clientHash);
         log.trace("H[H(N) xor H(g) | H(U)]: "+CryptoUtil.tob64(tmp.digest()));
      }
      // clientHash = H(N) xor H(g) | H(U) | s
      clientHash.update(params.s);
      if( log.isTraceEnabled() )
      {
View Full Code Here

      // clientHash = H(N) xor H(g) | H(U) | s
      clientHash.update(params.s);
      if( log.isTraceEnabled() )
      {
         MessageDigest tmp = CryptoUtil.copy(clientHash);
         log.trace("H[H(N) xor H(g) | H(U) | s]: "+CryptoUtil.tob64(tmp.digest()));
      }
      K = null;
   }
  
   /**
 
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.