Java Code Examples for org.whispersystems.signalservice.api.crypto.DigestingOutputStream#write()

The following examples show how to use org.whispersystems.signalservice.api.crypto.DigestingOutputStream#write() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DigestingRequestBody.java    From mollyim-android with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void writeTo(BufferedSink sink) throws IOException {
  DigestingOutputStream outputStream = outputStreamFactory.createFor(new SkippingOutputStream(contentStart, sink.outputStream()));
  byte[]                buffer       = new byte[8192];

  int read;
  long total = 0;

  while ((read = inputStream.read(buffer, 0, buffer.length)) != -1) {
    if (cancelationSignal != null && cancelationSignal.isCanceled()) {
      throw new IOException("Canceled!");
    }

    outputStream.write(buffer, 0, read);
    total += read;

    if (progressListener != null) {
      progressListener.onAttachmentProgress(contentLength, total);
    }
  }

  outputStream.flush();
  digest = outputStream.getTransmittedDigest();
}
 
Example 2
Source File: DigestingRequestBody.java    From libsignal-service-java with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void writeTo(BufferedSink sink) throws IOException {
  DigestingOutputStream outputStream = outputStreamFactory.createFor(sink.outputStream());
  byte[]                buffer       = new byte[8192];

  int read;
  long total = 0;

  while ((read = inputStream.read(buffer, 0, buffer.length)) != -1) {
    outputStream.write(buffer, 0, read);
    total += read;

    if (progressListener != null) {
      progressListener.onAttachmentProgress(contentLength, total);
    }
  }

  outputStream.flush();
  digest = outputStream.getTransmittedDigest();
}
 
Example 3
Source File: DigestingRequestBody.java    From bcm-android with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void writeTo(BufferedSink sink) throws IOException {
  DigestingOutputStream outputStream = outputStreamFactory.createFor(sink.outputStream());
  byte[]                buffer       = new byte[4096];

  int read;

  while ((read = inputStream.read(buffer, 0, buffer.length)) != -1) {
    outputStream.write(buffer, 0, read);
  }

  outputStream.flush();
  digest = outputStream.getTransmittedDigest();
}