Skip to content

Commit

Permalink
expose binary string of the hash
Browse files Browse the repository at this point in the history
  • Loading branch information
Baptouuuu committed Jan 25, 2023
1 parent 68861d9 commit 8cca147
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Changelog

## 1.2.0 - 2023-01-25

### Added

- `Innmind\Hash\Value::binary()`
5 changes: 5 additions & 0 deletions src/Value.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,9 @@ public function hex(): string
{
return $this->hex;
}

public function binary(): string
{
return \hex2bin($this->hex);
}
}
4 changes: 4 additions & 0 deletions tests/FunctionalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ public function testHash()
\hash_file($hash->toString(), 'fixtures/'.$file->name()->toString()),
$hash->ofFile($file)->hex(),
);
$this->assertSame(
\hex2bin(\hash_file($hash->toString(), 'fixtures/'.$file->name()->toString())),
$hash->ofFile($file)->binary(),
);
});
}
}

0 comments on commit 8cca147

Please sign in to comment.