Hashing

fs2.hashing.Hashing
See theHashing companion object
sealed trait Hashing[F[_]]

Capability trait that provides hashing.

The hasher method returns a fresh Hasher object as a resource. Hasher is a mutable object that supports incremental computation of hashes.

A Hasher instance should be created for each hash you want to compute, though Hasher objects may be reused to compute consecutive hashes. When doing so, care must be taken to ensure no concurrent usage.

The hashWith operation converts a Resource[F, Hasher[F]] to a Pipe[F, Byte, Hash]. The resulting pipe outputs a single Hash once the source byte stream terminates.

Alternatively, a Resource[F, Hasher[F]] can be used directly (via .use or via Stream.resource). The Hasher[F] trait provides lower level operations for computing hashes, both at an individual chunk level (via update and digest) and at stream level (e.g., via observe and drain).

Finally, the Hashing companion object offers utilities for computing pure hashes: hashPureStream and hashChunk.

Attributes

Companion
object
Source
Hashing.scala
Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Abstract methods

Returns a pipe that hashes the source byte stream and outputs the hash.

Returns a pipe that hashes the source byte stream and outputs the hash.

For more sophisticated use cases, such as writing the contents of a stream to a file while simultaneously computing a hash, use hasher or sha256 or similar to create a Hasher[F].

Attributes

Source
Hashing.scala
def hashWith(hasher: Resource[F, Hasher[F]]): (F, Byte) => Hash

Like hash but takes a Resource[F, Hasher[F]] instead of a HashAlgorithm.

Like hash but takes a Resource[F, Hasher[F]] instead of a HashAlgorithm.

Attributes

Source
Hashing.scala

Creates a new hasher using the specified hashing algorithm.

Creates a new hasher using the specified hashing algorithm.

The returned resource will fail with an exception during resource acquisition when the runtime platform does not support the specified hashing algorithm.

Attributes

Source
Hashing.scala

Creates a new hasher using the specified HMAC algorithm.

Creates a new hasher using the specified HMAC algorithm.

Attributes

Source
Hashing.scala