diff options
Diffstat (limited to 'nitrocli/src')
-rw-r--r-- | nitrocli/src/commands.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/nitrocli/src/commands.rs b/nitrocli/src/commands.rs index b5fc282..eac8549 100644 --- a/nitrocli/src/commands.rs +++ b/nitrocli/src/commands.rs @@ -616,7 +616,7 @@ pub fn otp_get( fn format_bytes(bytes: &[u8]) -> String { bytes .iter() - .map(|c| format!("{:x}", c)) + .map(|c| format!("{:02x}", c)) .collect::<Vec<_>>() .join("") } @@ -956,4 +956,11 @@ mod tests { let result = prepare_ascii_secret("Österreich"); assert!(result.is_err()); } + + #[test] + fn hex_string() { + assert_eq!(format_bytes(&[b' ']), "20"); + assert_eq!(format_bytes(&[b' ', b' ']), "2020"); + assert_eq!(format_bytes(&[b'\n', b'\n']), "0a0a"); + } } |