Skip to content

Conversation

@v1rtl
Copy link
Contributor

@v1rtl v1rtl commented Oct 4, 2021

each SHA algorithm in std/hash has their own class but since all of them have the same set of functions it'd be smart to have a common interface that all these classes implement.

This PR adds a hash/types.ts file which exports Sha and Message types for convinience.

Example use case:

import type { Sha } from 'https://deno.land/std/hash/types.ts'

const createHash = (algo: string, key: string): Sha => {
  // ...
}

this will also ease adding std/node/crypto createHmac function in the future

@v1rtl v1rtl changed the title feat(hash): use common Sha interface for Sha1, Sha256 and Shae512 feat(hash): use common Sha interface for Sha1, Sha256 and Sha512 Oct 4, 2021
@kt3k
Copy link
Member

kt3k commented Oct 5, 2021

Sorry for not mentioning this in hash/README explicitly, but we are in the process of deprecating std/hash
ref: #1025

this will also ease adding std/node/crypto createHmac function in the future

This makes sense to me. Maybe we move these types somewhere in std/node?

@v1rtl
Copy link
Contributor Author

v1rtl commented Oct 5, 2021

oh alright then

I don't think it makes sense to have it in node cuz there's already Hash class

and also I was planning on using SHA from std/hash but if it's going to be replaced with crypto.subtle I probably should use it instead

@v1rtl v1rtl closed this Oct 5, 2021
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.

2 participants