Пример #1
0
  public void update(byte[] data, int pos, int len) {
    int rem = len;

    while (rem > 0) {

      int space = BLOCK_SIZE - current_bytes;

      if (rem <= space) {

        current_hasher.update(data, pos, rem);

        current_bytes += rem;

        break;

      } else {

        if (block_hasher == null) {

          block_hasher = new MD4Hasher();
        }

        if (space == 0) {

          block_hasher.update(current_hasher.getDigest());

          current_hasher = new MD4Hasher();

          current_bytes = 0;

        } else {

          current_hasher.update(data, pos, space);

          pos += space;
          rem -= space;
          current_bytes += space;
        }
      }
    }
  }
Пример #2
0
  public byte[] getDigest() {
    // data that is a multiple of BLOCK_SIZE needs to have a null MD4 hash appended

    if (current_bytes == BLOCK_SIZE) {

      if (block_hasher == null) {

        block_hasher = new MD4Hasher();
      }

      block_hasher.update(current_hasher.getDigest());

      current_hasher = new MD4Hasher();
    }

    if (block_hasher == null) {

      return (current_hasher.getDigest());

    } else {

      if (current_bytes > 0) {

        block_hasher.update(current_hasher.getDigest());
      }

      return (block_hasher.getDigest());
    }
  }