Package org.bouncycastle.crypto.digests

Examples of org.bouncycastle.crypto.digests.MD5Digest


   *
   * @param data to calculate the MD5 hash over it
   * @return the md5 hash
   */
  public static byte[] generateMD5Hash(byte[] data) {
    MD5Digest digest = new MD5Digest();
    digest.update(data, 0, data.length);
    byte[] md5 = new byte[digest.getDigestSize()];
    digest.doFinal(md5, 0);
    return md5;
  }
View Full Code Here


      fis = new FileInputStream(file);
    } catch (FileNotFoundException e) {
      return null;
    }

    MD5Digest digest = new MD5Digest();
    DigestInputStream dis = new DigestInputStream(fis, digest);
    do {
      numRead = dis.read(buffer);
      if (numRead > 0) {
        digest.update(buffer, 0, numRead);
      }
    } while (numRead != -1);
    dis.close();
    fis.close();

    byte[] md5 = new byte[digest.getDigestSize()];
    digest.doFinal(md5, 0);

    return md5;
  }
View Full Code Here

        byte[] ls = new byte[label.length + seed.length];
        System.arraycopy(label, 0, ls, 0, label.length);
        System.arraycopy(seed, 0, ls, label.length, seed.length);

        byte[] prf = new byte[buf.length];
        hmac_hash(new MD5Digest(), s1, ls, prf);
        hmac_hash(new SHA1Digest(), s2, ls, buf);
        for (int i = 0; i < buf.length; i++)
        {
            buf[i] ^= prf[i];
        }
View Full Code Here

        {
            cipher = new BufferedAsymmetricBlockCipher(new ISO9796d1Encoding(new ElGamalEngine()));
        }
        else if (pad.equals("OAEPWITHMD5ANDMGF1PADDING"))
        {
            cipher = new BufferedAsymmetricBlockCipher(new OAEPEncoding(new ElGamalEngine(), new MD5Digest()));
        }
        else if (pad.equals("OAEPWITHSHA1ANDMGF1PADDING"))
        {
            cipher = new BufferedAsymmetricBlockCipher(new OAEPEncoding(new ElGamalEngine(), new SHA1Digest()));
        }
View Full Code Here

    static public class MD5WithRSAEncryption
        extends JDKISOSignature
    {
        public MD5WithRSAEncryption()
        {
            super("MD5withRSA/ISO9796-2", new MD5Digest(), new RSABlindedEngine());
        }
View Full Code Here

        byte[] ls = new byte[label.length + seed.length];
        System.arraycopy(label, 0, ls, 0, label.length);
        System.arraycopy(seed, 0, ls, label.length, seed.length);

        byte[] prf = new byte[buf.length];
        hmac_hash(new MD5Digest(), s1, ls, prf);
        hmac_hash(new SHA1Digest(), s2, ls, buf);
        for (int i = 0; i < buf.length; i++)
        {
            buf[i] ^= prf[i];
        }
View Full Code Here

        {
            cipher = new ISO9796d1Encoding(new RSAEngine());
        }
        else if (pad.equals("OAEPWITHMD5ANDMGF1PADDING"))
        {
            cipher = new OAEPEncoding(new RSAEngine(), new MD5Digest());
        }
        else if (pad.equals("OAEPWITHSHA1ANDMGF1PADDING"))
        {
            cipher = new OAEPEncoding(new RSAEngine(), new SHA1Digest());
        }
View Full Code Here

    public static class MD5
        extends JCEMac
    {
        public MD5()
        {
            super(new HMac(new MD5Digest()));
        }
View Full Code Here

    static public class MD5WithRSAEncryption
        extends JDKDigestSignature
    {
        public MD5WithRSAEncryption()
        {
            super("MD5withRSA", md5, new MD5Digest(), new PKCS1Encoding(new RSABlindedEngine()));
        }
View Full Code Here

   * @throws UnsupportedEncodingException
   * @throws UnknownHostException
   */
  public UUID getMachineId() throws UnsupportedEncodingException,
      SocketException, UnknownHostException {
    final MD5Digest md5 = new MD5Digest();
    md5.reset();
    if (useNetwork) {
      updateWithNetworkData(md5);
    }
    if (useHostName) {
      updateWithHostName(md5);
    }
    if (useArchitecture) {
      updateWithArchitecture(md5);
    }
    final byte[] digest = new byte[16];
    md5.doFinal(digest, 0);
    return UUID.nameUUIDFromBytes(digest);
  }
View Full Code Here

TOP

Related Classes of org.bouncycastle.crypto.digests.MD5Digest

Copyright © 2018 www.massapicom. 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.