computed data's hash by webAssembly

Overview

wasm-hasher

computed data's hash by webAssembly

support md5,sha1,sha2-224,sha2-356,sha2-384,sha2-512,sha3-224,sha3-256,sha3-384,sha3-512,china-sm3

type function params return
md5 md5 md5(blob,callback) promise
sha1 sha1 sha1(blob,callback) promise
sha2 sha2_224 sha2_224(blob,callback) promise
- sha2_256 sha2_256(blob,callback) promise
- sha2_384 sha2_384(blob,callback) promise
- sha2_512 sha2_512(blob,callback) promise
sha3 sha3_224 sha3_224(blob,callback) promise
- sha3_256 sha3_256(blob,callback) promise
- sha3_384 sha3_384(blob,callback) promise
- sha3_512 sha3_512(blob,callback) promise
sm3 sm3 sm3(blob,callback) promise

How to install

npm install @fuyoo/wasm-hasher

How to use

Webpack Demo

<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>MD5 ONLINE</title>
</head>

<body>
计算方式:<select id="type">
    <optgroup label="md5">
        <option value="md5">md5</option>
    </optgroup>
    <optgroup label="sha1">
        <option value="sha1">sha1</option>
    </optgroup>
    <optgroup label="sha2">
        <option value="sha2_224">sha2-224</option>
        <option value="sha2_256">sha2-256</option>
        <option value="sha2_384">sha2-384</option>
        <option value="sha2_512">sha2-512</option>
    </optgroup>
    <optgroup label="sha3">
        <option value="sha3_224">sha3-224</option>
        <option value="sha3_256">sha3-256</option>
        <option value="sha3_384">sha3-384</option>
        <option value="sha3_512">sha3-512</option>
        <option value="sha3_512">sha3-512</option>
    </optgroup>
    <optgroup label="国密">
        <option value="sm3">sm3</option>
    </optgroup>
</select>

<button id="file">选择文件</button>
<div id="fileinfo"></div>
<div id="progress"></div>
<div id="time"></div>
</body>
<script src="index.js"></script>
</html>
document.querySelector("#file")
    .addEventListener("click", function () {
        let progress = document.querySelector("#progress")
        let fileinfo = document.querySelector("#fileinfo")
        let time = document.querySelector("#time")
        let i = document.createElement("input")
        let t = document.querySelector("#type")
        i.type = "file"
        i.onchange = function () {
            reset()
            let file = (this.files[0])
            fileinfo.innerHTML = `文件名:${file.name} 共:${getSize(file.size)}`
            import ("@fuyoo/wasm-hasher")
                .then(pkg => {
                    console.log(pkg)
                    let start = Date.now()
                    pkg[t.value](file, (ps) => {
                        progress.innerHTML = `${t.value.toUpperCase()}计算中:已完成${(ps / 1.0).toFixed(2)}%`
                    }).then(res => {
                        progress.innerHTML = `${t.value.toUpperCase()}计算已完成`
                        time.innerHTML = `${t.value.toUpperCase()}: ${res}, 用时${(Date.now() - start) / 1000}s`
                    })
                })
        }
        i.click()

        function reset() {
            progress.innerHTML = ""
            fileinfo.innerHTML = ""
            time.innerHTML = ""
        }

        function getSize(size) {
            if (size < cf(1)) return size + "B"
            if (size >= cf(1) && size < cf(2)) return (size / cf(1)).toFixed(3) + "Kb"
            if (size >= cf(2) && size < cf(3)) return (size / cf(2)).toFixed(3) + "Mb"
            if (size >= cf(3) && size < cf(4)) return (size / cf(3)).toFixed(3) + "Gb"
            if (size >= cf(4) && size < cf(5)) return (size / cf(4)).toFixed(3) + "Tb"
            return (size / cf(1)).toFixed(3) + "Kb"

        }

        function cf(n) {
            let r = 1024
            for (let i = 1; i < n; i++) {
                r *= 1024
            }
            return r
        }
    })

license

MIT LICENSE

You might also like...
MD5/SHA256 HASH ATTACK IN RUST
MD5/SHA256 HASH ATTACK IN RUST

hashraccoon Installation Install cargo curl https://sh.rustup.rs -sSf | sh Install the hashraccoon crate cargo install hashraccoon Download the rockyo

Blazing fast Pedersen hash implementation for Node.JS

pedersen-fast Blazing fast Pedersen hash implementation for Node.JS Exposes starknet-crypto's implementation written in Rust as WASM package. Usage np

Hash trait that is object-safe

Hash trait that is object-safe This crate provides a DynHash trait that can be used in trait objects. Types that implement the standard library's std:

WebAssembly wrapper of the rage encryption library

rage-wasm: WebAssembly wrapper of rage rage is a simple, modern, and secure file encryption tool, using the age format. It features small explicit key

evm2near compiles Solidity contracts into NEAR WebAssembly contracts.

EVM → NEAR evm2near is a project for compiling EVM bytecode into wasm bytecode, with the particular goal of having that wasm artifact be executable on

Fast(er) AES-based constructions for WebAssembly and Rust.

Fast(er) AES-based constructions for Rust and WebAssembly AEGIS-128L AEGIS-256 AES-128-CTR AES-256-CTR AES-128-OCB AES-256-OCB AES-128-GCM AES-256-GCM

Computed file's md5 by webAssembly

Computed file's md5 by webAssembly

Rust implementation of the PTHash perfect hash function for static compile-time generated hash tables

QuickPHF QuickPHF is a Rust implementation of the PTHash minimal perfect hash function algorithm. It consists of two crates: quickphf - runtime code f

An asynchronous runtime compatible with WebAssembly and non-WebAssembly targets.

Promise x Tokio = Prokio An asynchronous runtime compatible with WebAssembly and non-WebAssembly targets. Rationale When designing components and libr

Highly modular & configurable hash & crypto library
Highly modular & configurable hash & crypto library

Octavo Highly modular & configurable hash & crypto library written in pure Rust. Installation [dependencies] octavo = { git = "https://github.com/libO

Collection of cryptographic hash functions written in pure Rust

RustCrypto: hashes Collection of cryptographic hash functions written in pure Rust. All algorithms reside in the separate crates and implemented using

A Rust library for calculating perceptual hash values of images

img_hash Now builds on stable Rust! (But needs nightly to bench.) A library for getting perceptual hash values of images. Thanks to Dr. Neal Krawetz f

A SIMD-accelerated Adler-32 rolling hash algorithm implementation.

simd-adler32 A SIMD-accelerated Adler-32 rolling hash algorithm implementation. Features No dependencies Support no_std (with default-features = false

The hash programming language compiler

The Hash Programming language Run Using the command cargo run hash. This will compile, build and run the program in the current terminal/shell. Submit

Hash Table Implementation in Rust
Hash Table Implementation in Rust

Hash Table Implementation in Rust Purely for educational and recreational purposes. For real world production please use std::collections::HashMap. Fo

Finds matching solidity function signatures for a given 4 byte signature hash and arguments.

Finds matching solidity function signatures for a given 4 byte signature hash and arguments. Useful for finding collisions or 0x00000000 gas saving methods (though there are better techniques for saving gas on calldata)

A rust binding for nodejs to generate md5 hash value

Hasher A rust binding for creating node module to generate md5 hash value This project was bootstrapped by create-neon. Installing hasher Installing h

Rust Blake hash bindings for Node.js.

@napi-rs/blake-hash Node.js binding for https://github.com/BLAKE3-team/BLAKE3. High performance, and no postinstall scripts. Support matrix node12 nod

Reference implementation for the Poseidon Snark-friendly Hash algorithm.

Dusk-Poseidon Reference implementation for the Poseidon Hashing algorithm. Reference Starkad and Poseidon: New Hash Functions for Zero Knowledge Proof

Owner
fuyoo
start by hello world, over off by hello world!
fuyoo
Highly modular & configurable hash & crypto library

Octavo Highly modular & configurable hash & crypto library written in pure Rust. Installation [dependencies] octavo = { git = "https://github.com/libO

Octavo Developers 139 Dec 29, 2022
Collection of cryptographic hash functions written in pure Rust

RustCrypto: hashes Collection of cryptographic hash functions written in pure Rust. All algorithms reside in the separate crates and implemented using

Rust Crypto 1.2k Jan 8, 2023
A rust binding for nodejs to generate md5 hash value

Hasher A rust binding for creating node module to generate md5 hash value This project was bootstrapped by create-neon. Installing hasher Installing h

Md. Al-Amin 0 Nov 7, 2021
Reference implementation for the Poseidon Snark-friendly Hash algorithm.

Dusk-Poseidon Reference implementation for the Poseidon Hashing algorithm. Reference Starkad and Poseidon: New Hash Functions for Zero Knowledge Proof

Dusk Network 96 Jan 2, 2023
the official Rust and C implementations of the BLAKE3 cryptographic hash function

BLAKE3 is a cryptographic hash function that is: Much faster than MD5, SHA-1, SHA-2, SHA-3, and BLAKE2. Secure, unlike MD5 and SHA-1. And secure again

BLAKE3 team 3.7k Jan 6, 2023
paq files to hash.

paq paq files to hash. Hash a single file or all files in directory recursively. Installation Requires cargo. Run cargo install paq. Usage Run paq [sr

gregory langlais 3 Oct 10, 2022
Fastmurmur3 - Fast non-cryptographic hash, with the benchmarks to prove it.

Fastmurmur3 Murmur3 is a fast, non-cryptographic hash function. fastmurmur3 is, in my testing, the fastest implementation of Murmur3. Usage let bytes:

Kurt Wolf 13 Dec 2, 2022
An implementation of Jakobsson's Fractal Hash Sequence Traversal algorithm

fractal-hash-traversal An implementation of Jakobsson's Fractal Hash Sequence Traversal algorithm. There is at least one hash traversal algorithm that

Dan Cline 1 Jan 12, 2022
Generates a unique hash/identifier for a system given a set of parameters.

uniqueid ?? Generates a unique hash/identifier for a system given a set of parameters. Example usage use uniqueid; pub fn main() { let data = vec

Checksum 2 Aug 19, 2022
Left To My Own Devices - NT hash tools

ntcrack Left To My Own Devices - NT cracker A full writeup of how it works is available at the SensePost blog Invocation ./ntcrack <input hashlist> <w

SensePost 24 Nov 24, 2022