Module esp32_hal::rom::md5

source ·
Expand description

§MD5 Message-Digest Algorithm

§⚠️ Security Warning ⚠️

MD5 is a cryptographically broken message digest. It should not be used for data security, for example, to check if data has been intentionally tampered with.

However, it is still very useful for purposes of data integrity, for example, to check if data has been accidentally tampered with, such as detecting data corrupted during transmission in a stream or stored in flash. This is especially important on microcontrollers where the computational efficiency of MD5 is desired.

§Compatibility

The public API exposed by this module tries to mimic the public API offered by the MD5 crate in an effort to act as a drop-in replacement. The actual implementation, however, links to whatever is available in the ROM of the particular ESP32 target. Each chip target may offer a different underlying MD5 implementation with varying functionality.

This module offers a least-common-denominator API to stay consistent with all of them. Usage of this module may help make program binaries smaller than it would be if you included an MD5 implementation in your project.

§Example

To compute a full digest from a single buffer, use the following:

let d: md5::Digest = md5::compute(&data);
writeln!(uart0, "{}", d);

To compute a digest over multiple buffers:

let mut ctx = md5::Context::new();
ctx.consume(&data0);
ctx.consume(&data1);
let d: md5::Digest = ctx.compute();
writeln!(uart0, "{}", d);

Structs§

  • MD5 context for an ongoing computation
  • 16-byte message digest

Functions§

  • Compute a full digest from a single buffer