Skip to content

feat: add sha384, sha512 support #282

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Jun 23, 2025
Merged

feat: add sha384, sha512 support #282

merged 12 commits into from
Jun 23, 2025

Conversation

lukasjhan
Copy link
Member

No description provided.

@lukasjhan lukasjhan self-assigned this Jun 9, 2025
@lukasjhan lukasjhan requested a review from Copilot June 9, 2025 04:52
Copilot

This comment was marked as outdated.

lukasjhan added 2 commits June 9, 2025 14:04
Signed-off-by: Lukas J Han <[email protected]>
lukasjhan and others added 2 commits June 10, 2025 17:59
Co-authored-by: Mirko Mollik <[email protected]>
Signed-off-by: Lukas.J.Han <[email protected]>
Signed-off-by: Lukas.J.Han <[email protected]>
@lukasjhan lukasjhan requested review from cre8, Copilot and berendsliedrecht and removed request for Copilot June 10, 2025 09:06
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds SHA-384 and SHA-512 support alongside the existing SHA-256 implementation.

  • Introduces sha384 and sha512 functions and extends hasher to handle those algorithms.
  • Updates tests to compare all three algorithms against Node’s crypto.createHash.
  • Bumps the @noble/hashes dependency to ^1.8.0 and re-exports from a consolidated sha2.ts.

Reviewed Changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.

File Description
packages/hash/src/test/sha2.spec.ts Renamed suite, added browser-skipped tests for SHA-256/384/512 on strings and ArrayBuffers
packages/hash/src/sha2.ts Added sha384, sha512 and updated hasher with a switch; adjusted imports
packages/hash/src/index.ts Updated export from sha256 to sha2
packages/hash/package.json Bumped @noble/hashes from 1.0.0 to ^1.8.0
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported
Comments suppressed due to low confidence (2)

packages/hash/src/sha2.ts:8

  • The function currently accepts ArrayBuffer but normalizes to Uint8Array internally. Consider updating the signature to (text: string | Uint8Array) to accurately reflect the input shape and avoid type mismatches.
export const sha256 = (text: string | ArrayBuffer): Uint8Array => {

packages/hash/src/test/sha2.spec.ts:128

  • There’s no test covering an unsupported algorithm in hasher. Adding a test that calls hasher(data, 'invalid-algo') and expects the Unsupported algorithm exception would ensure correct error handling.
describe('Hash', () => {

@cre8
Copy link
Contributor

cre8 commented Jun 16, 2025

@lukasjhan I think when we rename the one file + make clear that someone could also use their own hasher implementation, than this PR is fine.

@lukasjhan lukasjhan requested review from cre8 and TimoGlastra June 23, 2025 08:00
@cre8 cre8 merged commit 0a2f20b into main Jun 23, 2025
8 checks passed
@cre8 cre8 deleted the feat/add-hash-support branch June 23, 2025 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants