You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The problem is that each byte in the SHA1 digest is hexified individually in a way that doesn't include leading zeros: a byte of 0x0a just gets turned into 'a'. So if your digest should be "ab0e" the result is "abe". You can see in this program where the printed strings vary in length:
extern mod std;
use std::sha1;
fn main () {
let s = sha1::sha1 ();
let mut i = 0u8;
while i < 100 {
s.input (~[i]);
io::print (s.result_str () + "\n");
s.reset ();
i += 1;
}
}
Do the Rust standard libraries have a byte-array-to-hex converter somewhere? It seems like that'd be a useful thing to tuck in somewhere. Besides being incorrect for the time being, the SHA1 hex converter also looks like it's probably slower than it needs to be.
The text was updated successfully, but these errors were encountered:
The problem is that each byte in the SHA1 digest is hexified individually in a way that doesn't include leading zeros: a byte of 0x0a just gets turned into 'a'. So if your digest should be "ab0e" the result is "abe". You can see in this program where the printed strings vary in length:
Do the Rust standard libraries have a byte-array-to-hex converter somewhere? It seems like that'd be a useful thing to tuck in somewhere. Besides being incorrect for the time being, the SHA1 hex converter also looks like it's probably slower than it needs to be.
The text was updated successfully, but these errors were encountered: