pub fn encode_string(
dst: &mut [u8],
algorithm: Algorithm,
version: Version,
params: &Params,
salt: &[u8],
hash: &[u8],
) -> Result<usize, Error>Expand description
encode_string(dst, dst_len, ctx, type).
Writes the PHC string into dst (no NUL terminator) and returns its length.
Always emits $v=, as the C does.
dst must hold the string plus one byte, because the C reserves room
for its NUL terminator and this port keeps the capacity rule identical:
a buffer of exactly encoded_len bytes is what succeeds, in Rust and in
C alike.
hash.len() plays the role of ctx->outlen — it is the length that gets
encoded, so it, and not Params::tag_len_bytes, is what the leading
validate_inputs() checks. For a tag produced from these params the two
are the same value.
§Errors
Error::EncodingFail if dst is too small, or whatever
crate::params::validate_inputs returns — encode_string runs it first,
exactly like the C.