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

#654 in WebAssembly

Download history 33/week @ 2024-07-20 46/week @ 2024-07-27 130/week @ 2024-08-03 71/week @ 2024-08-10 81/week @ 2024-08-17 86/week @ 2024-08-24 175/week @ 2024-08-31 38/week @ 2024-09-07 54/week @ 2024-09-14 101/week @ 2024-09-21 47/week @ 2024-09-28 74/week @ 2024-10-05 54/week @ 2024-10-12 62/week @ 2024-10-19 71/week @ 2024-10-26 99/week @ 2024-11-02

301 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