From 814edcdd570b3fbef2001f7e6434320743a8f834 Mon Sep 17 00:00:00 2001 From: Felipe Baltor Date: Mon, 26 Jun 2023 23:04:49 -0300 Subject: test(ext/node): port crypto_test.ts from deno_std (#19561) --- ext/node/ops/crypto/digest.rs | 13 +++++++++++++ ext/node/ops/crypto/mod.rs | 5 +++++ 2 files changed, 18 insertions(+) (limited to 'ext/node/ops') diff --git a/ext/node/ops/crypto/digest.rs b/ext/node/ops/crypto/digest.rs index 4fab58a43..685fc32d0 100644 --- a/ext/node/ops/crypto/digest.rs +++ b/ext/node/ops/crypto/digest.rs @@ -99,6 +99,19 @@ impl Hash { Sha512(context) => context.finalize(), } } + + pub fn get_hashes() -> Vec<&'static str> { + vec![ + "md4", + "md5", + "ripemd160", + "sha1", + "sha224", + "sha256", + "sha384", + "sha512", + ] + } } impl Clone for Hash { diff --git a/ext/node/ops/crypto/mod.rs b/ext/node/ops/crypto/mod.rs index a83263fff..1155a4d15 100644 --- a/ext/node/ops/crypto/mod.rs +++ b/ext/node/ops/crypto/mod.rs @@ -88,6 +88,11 @@ pub fn op_node_create_hash(state: &mut OpState, algorithm: &str) -> u32 { }) } +#[op(fast)] +pub fn op_node_get_hashes() -> Vec<&'static str> { + digest::Hash::get_hashes() +} + #[op(fast)] pub fn op_node_hash_update(state: &mut OpState, rid: u32, data: &[u8]) -> bool { let context = match state.resource_table.get::(rid) { -- cgit v1.2.3