diff options
author | matthew seyer <matthew.seyer@gmail.com> | 2017-04-21 06:42:12 +0300 |
---|---|---|
committer | matthew seyer <matthew.seyer@gmail.com> | 2017-04-21 06:42:12 +0300 |
commit | c103f961ffca9828fb4ce36a836ea75532df0841 (patch) | |
tree | b39b3c2a6e22289a37e37f7865ad7e3f0007698c /src/utils.rs | |
parent | 1e51b18c8abe4e7b7b437ae26301dcac6ba8bbf8 (diff) |
initial commit
Diffstat (limited to 'src/utils.rs')
-rw-r--r-- | src/utils.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/utils.rs b/src/utils.rs new file mode 100644 index 0000000..7bda5c9 --- /dev/null +++ b/src/utils.rs @@ -0,0 +1,10 @@ +pub fn to_hex_string(bytes: &Vec<u8>) -> String { + let strs: Vec<String> = bytes.iter() + .map(|b| format!("{:02X}", b)) + .collect(); + strs.join("") +} + +pub fn print_buffer_as_hex(buffer: &[u8]) { + println!("{}",to_hex_string(&buffer.to_vec())); +} |