How do I make the crypto.subtle.digest algo flexible?
This is a learning moment, bear with me.
I can hard code an algo for the digest like this:
But if I want to make the algo flexible, it forces me to make it a DigestAlgorithm and it cannot be a string shown here:
I reviewed what that is in the source:
https://github.com/denoland/deno_std/blob/main/crypto/_wasm/mod.ts
I see this:
(I don't quite see what is going on here and am interested.)
Bottom line is, when I make algo:string a algo:DigestAlgorithm in the digest function param list, it stops complaining, but I need to have some calling code somewhere be a flexible string (or maybe an enum if necessary) that somehow translates to a DigestAlgorithm for this to work.
I've been struggling with this. Any ideas?
I can hard code an algo for the digest like this:
But if I want to make the algo flexible, it forces me to make it a DigestAlgorithm and it cannot be a string shown here:
I reviewed what that is in the source:
https://github.com/denoland/deno_std/blob/main/crypto/_wasm/mod.ts
I see this:
export type DigestAlgorithm = typeof digestAlgorithms[number];(I don't quite see what is going on here and am interested.)
Bottom line is, when I make algo:string a algo:DigestAlgorithm in the digest function param list, it stops complaining, but I need to have some calling code somewhere be a flexible string (or maybe an enum if necessary) that somehow translates to a DigestAlgorithm for this to work.
I've been struggling with this. Any ideas?
