1
Fork 0

Remove vecs from std::sha1

This commit is contained in:
Brian Anderson 2011-08-11 23:54:26 -07:00
parent 235109f8d2
commit f9623f0056
2 changed files with 6 additions and 19 deletions

View file

@ -25,11 +25,9 @@ type sha1 =
// Reset the sha1 state for reuse. This is called
// automatically during construction
obj {
fn input(&vec[u8]) ;
fn input_ivec(&[u8]) ;
fn input(&[u8]) ;
fn input_str(&str) ;
fn result() -> vec[u8] ;
fn result_ivec() -> [u8] ;
fn result() -> [u8] ;
fn result_str() -> str ;
fn reset() ;
};
@ -239,20 +237,9 @@ fn mk_sha1() -> sha1 {
st.h.(4) = 0xC3D2E1F0u32;
st.computed = false;
}
fn input(msg: &vec[u8]) {
let m = ~[];
for b: u8 in msg { m += ~[b]; }
add_input(st, m);
}
fn input_ivec(msg: &[u8]) { add_input(st, msg); }
fn input(msg: &[u8]) { add_input(st, msg); }
fn input_str(msg: &str) { add_input(st, str::bytes(msg)); }
fn result() -> vec[u8] {
let rivec = mk_result(st);
let rvec = [];
for b: u8 in rivec { rvec += [b]; }
ret rvec;
}
fn result_ivec() -> [u8] { ret mk_result(st); }
fn result() -> [u8] { ret mk_result(st); }
fn result_str() -> str {
let r = mk_result(st);
let s = "";

View file

@ -76,7 +76,7 @@ fn test() {
let sh = sha1::mk_sha1();
for t: test in tests {
sh.input_str(t.input);
let out = sh.result_ivec();
let out = sh.result();
check_vec_eq(t.output, out);
sh.reset();
}
@ -91,7 +91,7 @@ fn test() {
sh.input_str(str::substr(t.input, len - left, take));
left = left - take;
}
let out = sh.result_ivec();
let out = sh.result();
check_vec_eq(t.output, out);
sh.reset();
}