arnaucube
arnaucube/miden-cryptoPublic Self-hosted repository
miden-crypto/src/utils.rs
src/utils.rsRaw
 1use super::Word;
 2use crate::utils::string::String;
 3use core::fmt::{self, Write};
 4
 5// RE-EXPORTS
 6// ================================================================================================
 7pub use winter_utils::{
 8    collections, string, uninit_vector, ByteReader, ByteWriter, Deserializable,
 9    DeserializationError, Serializable, SliceReader,
10};
11
12/// Converts a [Word] into hex.
13pub fn word_to_hex(w: &Word) -> Result<String, fmt::Error> {
14    let mut s = String::new();
15
16    for byte in w.iter().flat_map(|e| e.to_bytes()) {
17        write!(s, "{byte:02x}")?;
18    }
19
20    Ok(s)
21}