You are here

function hash in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/guzzlehttp/psr7/src/functions.php \GuzzleHttp\Psr7\hash()

Calculate a hash of a Stream

Parameters

StreamInterface $stream Stream to calculate the hash for:

string $algo Hash algorithm (e.g. md5, crc32, etc):

bool $rawOutput Whether or not to use raw output:

Return value

string Returns the hash of the stream

Throws

\RuntimeException on error.

5 string references to 'hash'
Feed::setHash in core/modules/aggregator/src/Entity/Feed.php
Sets the calculated hash of the feed data, used for validating cache.
MigrateSqlIdMapEnsureTablesTest::testEnsureTablesExist in core/modules/migrate/tests/src/Unit/MigrateSqlIdMapEnsureTablesTest.php
Tests the ensureTables method when the tables exist.
Sql::ensureTables in core/modules/migrate/src/Plugin/migrate/id_map/Sql.php
Create the map and message tables if they don't already exist.
SqlContentEntityStorageSchemaTest::testGetSchemaBase in core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageSchemaTest.php
Tests the schema for non-revisionable, non-translatable entities.
system_requirements in core/modules/system/system.install
Implements hook_requirements().

File

vendor/guzzlehttp/psr7/src/functions.php, line 383

Namespace

GuzzleHttp\Psr7

Code

function hash(StreamInterface $stream, $algo, $rawOutput = false) {
  $pos = $stream
    ->tell();
  if ($pos > 0) {
    $stream
      ->rewind();
  }
  $ctx = hash_init($algo);
  while (!$stream
    ->eof()) {
    hash_update($ctx, $stream
      ->read(1048576));
  }
  $out = hash_final($ctx, (bool) $rawOutput);
  $stream
    ->seek($pos);
  return $out;
}