Package java.security

Examples of java.security.MessageDigest.reset()


        byte[] K = sha.digest(pwSalt);
        /*
         * Perform the 2nd up to iteration hash rounds
         */
        for (int i = 2; i <= iteration; i++) {
            sha.reset();
            K = sha.digest(K);
        }
        return K;
    }

View Full Code Here


        try {
            sha = MessageDigest.getInstance("SHA-1");
        } catch (NoSuchAlgorithmException e1) {
            throw new WSSecurityException(0, "noSHA1availabe");
        }
        sha.reset();
        try {
            sha.update(cert.getEncoded());
        } catch (CertificateEncodingException e1) {
            throw new WSSecurityException(
                    WSSecurityException.SECURITY_TOKEN_UNAVAILABLE,
View Full Code Here

                    cert = certs[0];
                }
                if (!(cert instanceof X509Certificate)) {
                    continue;
                }
                sha.reset();
                try {
                    sha.update(cert.getEncoded());
                } catch (CertificateEncodingException e1) {
                    throw new WSSecurityException(
                            WSSecurityException.SECURITY_TOKEN_UNAVAILABLE,
View Full Code Here

                throw new WSSecurityException(
                        1,
                        "noSKIHandling",
                        new Object[]{"Wrong certificate version (<3) and no SHA1 message digest availabe"});
            }
            sha.reset();
            sha.update(value);
            return sha.digest();
        }

        /**
 
View Full Code Here

  private byte[] computeHash(InputStream in, long length) throws IOException {
    final MessageDigest contentDigest = state.contentDigest;
    final byte[] contentReadBuffer = state.contentReadBuffer;

    contentDigest.reset();
    contentDigest.update(hblob);
    contentDigest.update((byte) ' ');

    long sz = length;
    if (sz == 0) {
View Full Code Here

        } catch (Exception e) {
            _.die("Failed to get SHA, shouldn't happen");
            return "";
        }

        algorithm.reset();
        algorithm.update(fileContents);
        byte messageDigest[] = algorithm.digest();
        StringBuilder sb = new StringBuilder();
        for (byte aMessageDigest : messageDigest) {
            sb.append(String.format("%02x", 0xFF & aMessageDigest));
View Full Code Here

        return HashUtil.byteToBase64(getHash(HASH_ITERATIONS, token, salt.getBytes()));
    }

    public byte[] getHash(int numberOfIterations, String password, byte[] salt) throws Exception {
       MessageDigest digest = MessageDigest.getInstance("SHA-256");
       digest.reset();
       digest.update(salt);
       byte[] input = digest.digest(password.getBytes("UTF-8"));
       for (int i = 0; i < numberOfIterations; i++) {
           digest.reset();
           input = digest.digest(input);
View Full Code Here

       MessageDigest digest = MessageDigest.getInstance("SHA-256");
       digest.reset();
       digest.update(salt);
       byte[] input = digest.digest(password.getBytes("UTF-8"));
       for (int i = 0; i < numberOfIterations; i++) {
           digest.reset();
           input = digest.digest(input);
       }
       return input;
   }
View Full Code Here

            if( encRevision == 3 || encRevision == 4)
            {
                for( int i=0; i < 50; i++ )
                {
                    md.reset();
                    md.update( digest, 0, length );
                    digest = md.digest();
                }
            }
View Full Code Here

   * @return String The hased name.
   */
  public static String hashedName(String s) {
    try {
      MessageDigest md = MessageDigest.getInstance( "MD5" );
      md.reset();
      md.update( s.getBytes() );
      byte[] digest = md.digest();
      BigInteger bigInt = new BigInteger( 1, digest );
      // By converting to base 35 (full alphanumeric), we guarantee
      // that the length of the name will always be smaller than the 30
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.