Skip to content

Commit 511607f

Browse files
authored
mcf: rename McfHash::push_field_base64 to McfHash::push_base64 (#2030)
Slightly shorter and matches the other methods, also it doesn't act on a `Field` type so the old name was slightly confusing.
1 parent f85f8eb commit 511607f

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mcf/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "mcf"
3-
version = "0.1.0"
3+
version = "0.2.0-pre"
44
authors = ["RustCrypto Developers"]
55
edition = "2024"
66
rust-version = "1.85"

mcf/src/lib.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -160,21 +160,21 @@ mod allocating {
160160
self.as_mcf_hash_ref().fields()
161161
}
162162

163-
/// Push an additional field onto the password hash string, first adding a leading `$`.
164-
pub fn push_field(&mut self, field: Field<'_>) {
163+
/// Encode the given data as the specified variant of Base64 and push it onto the password
164+
/// hash string, first adding a `$` delimiter.
165+
pub fn push_base64(&mut self, field: &[u8], base64_encoding: Base64) {
165166
self.0.push(fields::DELIMITER);
166-
self.0.push_str(field.as_str());
167+
self.0.push_str(&base64_encoding.encode_string(field));
167168
}
168169

169-
/// Push an additional field onto the password hash string, adding a leading `$` and then
170-
/// encoding it into the specified variant of Base64.
171-
pub fn push_field_base64(&mut self, field: &[u8], base64_encoding: Base64) {
170+
/// Push an additional field onto the password hash string, first adding a `$` delimiter.
171+
pub fn push_field(&mut self, field: Field<'_>) {
172172
self.0.push(fields::DELIMITER);
173-
self.0.push_str(&base64_encoding.encode_string(field));
173+
self.0.push_str(field.as_str());
174174
}
175175

176-
/// Push a raw string onto the MCF hash, ensuring it validates as a [`Field`] and also
177-
/// adding a leading `$`.
176+
/// Push a raw string onto the MCF hash, first adding a `$` delimiter and also ensuring it
177+
/// validates as a [`Field`].
178178
///
179179
/// # Errors
180180
/// - If the provided `str` fails to validate as a [`Field`] (i.e. contains characters

mcf/tests/mcf.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ fn parse_sha512_hash() {
6565
#[test]
6666
fn push_fields() {
6767
let mut hash = McfHash::new("$6$rounds=100000").unwrap();
68-
hash.push_field_base64(EXAMPLE_SALT, Base64::ShaCrypt);
69-
hash.push_field_base64(EXAMPLE_HASH, Base64::ShaCrypt);
68+
hash.push_base64(EXAMPLE_SALT, Base64::ShaCrypt);
69+
hash.push_base64(EXAMPLE_HASH, Base64::ShaCrypt);
7070
assert_eq!(SHA512_HASH, hash.as_str());
7171
}

0 commit comments

Comments
 (0)