Skip to content

Commit

Permalink
Update CID.php
Browse files Browse the repository at this point in the history
  • Loading branch information
puklipo committed Dec 12, 2024
1 parent a7053e0 commit 369564a
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/Support/CID.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public static function verify(string $data, string $cid, ?int $codec = null): bo
$codec = self::decode($cid)['codec'];
}

return self::encode(data: $data, codec: $codec) === $cid;
return hash_equals($cid, self::encode(data: $data, codec: $codec));
}

/**
Expand Down Expand Up @@ -83,8 +83,6 @@ public static function decode(string $cid): array
$bytes = Multibase::decode($cid);

$version = Varint::decode(substr($bytes, 0, 1));
throw_unless(self::CID_V1 === $version);

$codec = Varint::decode(substr($bytes, 1, 1));
$hash_algo = Varint::decode(substr($bytes, 2, 1));
$hash_length = Varint::decode(substr($bytes, 3, 1));
Expand Down

0 comments on commit 369564a

Please sign in to comment.