5 releases

0.1.5 Aug 11, 2022
0.1.4 Mar 24, 2022
0.1.3 Mar 24, 2022
0.1.1 Mar 24, 2022
0.1.0 Mar 24, 2022

#651 in WebAssembly

Download history 71/week @ 2024-03-11 62/week @ 2024-03-18 16/week @ 2024-03-25 26/week @ 2024-04-01 37/week @ 2024-04-08 11/week @ 2024-04-15 80/week @ 2024-04-22 123/week @ 2024-04-29 32/week @ 2024-05-06 25/week @ 2024-05-13 61/week @ 2024-05-20 123/week @ 2024-05-27 95/week @ 2024-06-03 91/week @ 2024-06-10 124/week @ 2024-06-17 141/week @ 2024-06-24

480 downloads per month
Used in onetime-cli

MIT license

11KB
218 lines

md5-rs

A simple MD5 implementation with a focus on buffered reading, and is completely no_std.

This shouldn't be used in any security-critical software, as MD5 is vulnerable.

Motivations

I was working on a web project and realized I have no way of getting a checksum of a big file without reading it all into memory (which in some cases crashes the page!). The Web Crypto API doesn't have a MD5 implementation, so I figured rather than re-implementing a SHA algorithm, I'd implement MD5.

As such, the API may be slightly odd since it is mainly focused on WebAssembly.

Usage

This isn't as straight forward as other MD5 libraries may be, given that it is no_std through and through.

use md5_rs::Context;

// get the hash
let mut ctx = Context::new();
ctx.read(b"Hello, world");
let digest = ctx.finish();

// get digest as string
let hash = digest.iter().map(|x| format!("{:02x}", x)).collect::<String>();
println!("{hash}"); // "bc6e6f16b8a077ef5fbc8d59d0b931b9"

No runtime deps