diff options
author | Casper Beyer <caspervonb@pm.me> | 2021-02-02 19:05:46 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-02 12:05:46 +0100 |
commit | 6abf126c2a7a451cded8c6b5e6ddf1b69c84055d (patch) | |
tree | fd94c013a19fcb38954844085821ec1601c20e18 /std/hash/_wasm/src/lib.rs | |
parent | a2b5d44f1aa9d64f448a2a3cc2001272e2f60b98 (diff) |
chore: remove std directory (#9361)
This removes the std folder from the tree.
Various parts of the tests are pretty tightly dependent
on std (47 direct imports and 75 indirect imports, not
counting the cli tests that use them as fixtures) so I've
added std as a submodule for now.
Diffstat (limited to 'std/hash/_wasm/src/lib.rs')
-rw-r--r-- | std/hash/_wasm/src/lib.rs | 51 |
1 files changed, 0 insertions, 51 deletions
diff --git a/std/hash/_wasm/src/lib.rs b/std/hash/_wasm/src/lib.rs deleted file mode 100644 index 7e72a7471..000000000 --- a/std/hash/_wasm/src/lib.rs +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. - -use digest::{Digest, DynDigest}; -use wasm_bindgen::prelude::*; - -#[wasm_bindgen] -pub struct DenoHash { - inner: Box<dyn DynDigest>, -} - -#[wasm_bindgen] -pub fn create_hash(algorithm: &str) -> Result<DenoHash, JsValue> { - let hash: Option<Box<dyn DynDigest>> = match algorithm { - "md2" => Some(Box::new(md2::Md2::new())), - "md4" => Some(Box::new(md4::Md4::new())), - "md5" => Some(Box::new(md5::Md5::new())), - "ripemd160" => Some(Box::new(ripemd160::Ripemd160::new())), - "ripemd320" => Some(Box::new(ripemd320::Ripemd320::new())), - "sha1" => Some(Box::new(sha1::Sha1::new())), - "sha224" => Some(Box::new(sha2::Sha224::new())), - "sha256" => Some(Box::new(sha2::Sha256::new())), - "sha384" => Some(Box::new(sha2::Sha384::new())), - "sha512" => Some(Box::new(sha2::Sha512::new())), - "sha3-224" => Some(Box::new(sha3::Sha3_224::new())), - "sha3-256" => Some(Box::new(sha3::Sha3_256::new())), - "sha3-384" => Some(Box::new(sha3::Sha3_384::new())), - "sha3-512" => Some(Box::new(sha3::Sha3_512::new())), - "keccak224" => Some(Box::new(sha3::Keccak224::new())), - "keccak256" => Some(Box::new(sha3::Keccak256::new())), - "keccak384" => Some(Box::new(sha3::Keccak384::new())), - "keccak512" => Some(Box::new(sha3::Keccak512::new())), - _ => None, - }; - - if let Some(h) = hash { - Ok(DenoHash { inner: h }) - } else { - let err_msg = format!("unsupported hash algorithm: {}", algorithm); - Err(JsValue::from_str(&err_msg)) - } -} - -#[wasm_bindgen] -pub fn update_hash(hash: &mut DenoHash, data: &[u8]) { - hash.inner.update(data) -} - -#[wasm_bindgen] -pub fn digest_hash(hash: &mut DenoHash) -> Box<[u8]> { - hash.inner.finalize_reset() -} |