Skip to content

Commit

Permalink
crc32 for PHP < 7.4 apparently
Browse files Browse the repository at this point in the history
  • Loading branch information
paragonie-security committed Apr 19, 2024
1 parent 2689ae5 commit ffc160e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/JsonFieldMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ public static function fromString($string)
{
$crc32 = Binary::safeSubstr($string, 0, 8);
$json = Binary::safeSubstr($string, 8);
$calc = hash('crc32c', $json);
$calc = hash('crc32', $json);
if (!Util::hashEquals($calc, $crc32)) {
throw new CipherSweetException("CRC32C invalid; was config corrupted?");
throw new CipherSweetException("CRC32 invalid; was config corrupted?");
}

$decoded = \json_decode($json, true);
Expand Down Expand Up @@ -193,7 +193,7 @@ public function getMapping()
public function toString()
{
$json = \json_encode(['fields' => $this->fields]);
$crc = \hash('crc32c', $json);
$crc = \hash('crc32', $json);
return $crc . $json;
}

Expand Down

0 comments on commit ffc160e

Please sign in to comment.