Examples of MD5


Examples of ch.ethz.ssh2.crypto.digest.MD5

      throws IOException
  {
    if (salt.length < 8)
      throw new IllegalArgumentException("Salt needs to be at least 8 bytes for key generation.");

    MD5 md5 = new MD5();

    byte[] key = new byte[keyLen];
    byte[] tmp = new byte[md5.getDigestLength()];

    while (true)
    {
      md5.update(password, 0, password.length);
      md5.update(salt, 0, 8); // ARGH we only use the first 8 bytes of the salt in this step.
      // This took me two hours until I got AES-xxx running.

      int copy = (keyLen < tmp.length) ? keyLen : tmp.length;

      md5.digest(tmp, 0);

      System.arraycopy(tmp, 0, key, key.length - keyLen, copy);

      keyLen -= copy;

      if (keyLen == 0)
        return key;

      md5.update(tmp, 0, tmp.length);
    }
  }
View Full Code Here

Examples of ch.ethz.ssh2.crypto.digest.MD5

  {
    Digest dig = null;

    if ("md5".equals(type))
    {
      dig = new MD5();
    }
    else if ("sha1".equals(type))
    {
      dig = new SHA1();
    }
View Full Code Here

Examples of com.knowgate.misc.MD5

  // ---------------------------------------------------------------------------

  public static String computeContentMD5(byte[] byArray) {
    String sContentMD5;
    MD5 oMd5 = new MD5();
    oMd5.Init();
    oMd5.Update(byArray);
    sContentMD5 = Gadgets.toHexString(oMd5.Final());
    oMd5 = null;
    return sContentMD5;
  }
View Full Code Here

Examples of com.knowgate.misc.MD5

    short iRetVal;
    long lNow = new Date().getTime();
    if (lTimestamp+lTimeout<lNow) {
      iRetVal = CAPTCHA_TIMEOUT;
    } else {
      MD5 oCaptchaMd5 = new MD5(sPlainCaptcha+ACL.getRC4key());
      if (sPlainCaptchaMD5.equalsIgnoreCase(oCaptchaMd5.asHex()))
      iRetVal = (short) 0;
    else
        iRetVal = CAPTCHA_MISMATCH;
    } // fi (lTimestamp+lCaptchaTimeout<lNow)
    return iRetVal;
View Full Code Here

Examples of com.knowgate.misc.MD5

  }

  @ValidationMethod(on="save")
  public void validate(ValidationErrors errors) {

    MD5 oMD5 = new MD5(getCaptcha()+ACL.getRC4key());

    if (!oMD5.asHex().equals(getSessionAttribute("captcha_key")) && false) {

      try {
        connect();
        DAO.log(getSession(), user.getClass(), "CAPTCHA MISMATCH", AtrilEvent.Level.WARNING, ";"+user.getEmail());
        disconnect();
      } catch (StorageException ignore) { }

      Log.out.warn("Captch mismatch: signature "+oMD5.asHex()+" for text "+getCaptcha()+" does not match session signature "+getSessionAttribute("captcha_key"));

      errors.add("captcha", new LocalizableError("com.zesped.action.SignUpForm.captchaMismatch"));      

    } else {
   
View Full Code Here

Examples of com.trilead.ssh2.crypto.digest.MD5

    /**
     * Compresses a string into an integer with MD5.
     */
    private int md5(String s) {
        MD5 md5 = new MD5();
        md5.update(s.getBytes());
        byte[] digest = new byte[16];
        md5.digest(digest);

        // 16 bytes -> 4 bytes
        for (int i=0; i<4; i++)
            digest[i] ^= digest[i+4]+digest[i+8]+digest[i+12];
        return (b2i(digest[0])<< 24)|(b2i(digest[1])<<16)|(b2i(digest[2])<< 8)|b2i(digest[3]);
View Full Code Here

Examples of com.twmacinta.util.MD5

  private Random random = new Random();

  public String getCacheKey(CacheContext context) {
    try {
      MD5 md5 = new MD5();
      StringBuilder toHash = new StringBuilder(BASE_KEY_LENGTH);
      if (context instanceof CacheContextImpl) {
        CacheContextImpl cci = (CacheContextImpl) context;
        for (Map.Entry<String, Object> entry : cci.entries()) {
          md5.Update(entry.getKey(), ENCODING);
          md5.Update(":");
          if (log.isDebugEnabled()) {
            toHash.append(entry.getKey());
            toHash.append(":");
          }
          Object value = entry.getValue();
          if (null != value) {
            String cid = getCacheId(value);
            md5.Update(cid, ENCODING);
            if (log.isDebugEnabled()) {
              toHash.append(cid);
            }
          }
          md5.Update("-");
          if (log.isDebugEnabled()) {
            toHash.append("-");
          }
        }
      } else {
        String cid = getCacheId(context);
        md5.Update(cid, ENCODING);
        if (log.isDebugEnabled()) {
          toHash.append(cid);
        }
      }
      String key = md5.asHex();
      if (log.isDebugEnabled()) {
        log.debug("key for context {} which is a hash for {}", key, forceAscii(toHash));
      }
      return key;
    } catch (UnsupportedEncodingException uee) {
View Full Code Here

Examples of com.twmacinta.util.MD5

     * @return
     */
    public byte[] md5It(String s) {
        byte bb[] = new byte[16];
        try {
            MD5 md2 = new MD5(s.getBytes());
            return md2.doFinal();
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return bb;
View Full Code Here

Examples of com.twmacinta.util.MD5

        try {
            byte tmp[] = new byte[l];
            for(int i=0; i<l;i++) {
                tmp[i] = s[i];
            }
            MD5 md2 = new MD5(tmp);
            return md2.doFinal();
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return bb;
View Full Code Here

Examples of com.twmacinta.util.MD5

        String s1 = "";
        try
        {
      // Fast MD5 by Timothy W Macinta
      // http://www.twmacinta.com/myjava/fast_md5.php
            MD5 md5 = new MD5();
            md5.Update(s);
            s1 = md5.asHex();
        }
        catch(Exception exception)
        {
            System.out.println(exception);
        }
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.