Hashing Source
A source that computes a hash of the full stream of bytes it has supplied. To use, create an instance with your preferred hash algorithm. Exhaust the source by reading all of its bytes and then call hash to compute the final hash value.
In this example we use HashingSource
with a BufferedSource to make reading from the source easier.
HashingSource hashingSource = HashingSource.sha256(rawSource);
BufferedSource bufferedSource = Okio.buffer(hashingSource);
... // Read all of bufferedSource.
ByteString hash = hashingSource.hash();
A source that computes a hash of the full stream of bytes it has supplied. To use, create an instance with your preferred hash algorithm. Exhaust the source by reading all of its bytes and then call hash to compute the final hash value.
In this example we use HashingSource
with a BufferedSource to make reading from the source easier.
HashingSource hashingSource = HashingSource.sha256(rawSource);
BufferedSource bufferedSource = Okio.buffer(hashingSource);
... // Read all of bufferedSource.
ByteString hash = hashingSource.hash();