This crate is a clone of the linux crypt command.
It is a wrapper for the crypto algorithms used in crypt - Md5, blowfish, SHA256 and SHA512.
The algorithm is chosen based on the first 3 characters of the secret. If it starts with
$x$ where x is one of
1, 2, 3, 5 or 6.
Till this release (0.1), only MD5($1$), SHA256 ($5$) and SHA512 ($6$) are supported.
The package is provided for the purposes of interoperability with protocols and systems that mandate the use of MD5. However, MD5 should be considered cryptographically broken and unsuitable for further use. Collision attacks against MD5 are both practical and trivial, and theoretical attacks against MD5 have been found. RFC6151 advises no new protocols to be designed with any MD5-based constructions, including HMAC-MD5.
To add crypt to your package, add this to your Cargo.toml:
[dependencies] crypt3 = "0.1"
use crypt3::crypt; let digest = crypt(b"abcdefghijklmnop", b"$1$"); assert_eq!(digest.unwrap(), [36, 49, 36, 36, 29, 100, 220, 226, 57, 196, 67, 123, 119, 54, 4, 29, 176, 137, 225, 185]);
This function is the entry point of the crate. It accepts 2 byte slices - a to-be-hashed password and a salt. The first 3 bytes of the salt decide which algorithm is picked and should be in the $id$ form (e.g. $1$ for MD5).