Skip to content

Commit 90a12d0

Browse files
committed
---
yaml --- r: 1881 b: refs/heads/master c: e99feab h: refs/heads/master i: 1879: 5ff4f14 v: v3
1 parent 4b45e9a commit 90a12d0

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: ac6e1131e91d27f1211e028587e5f68e2900cdd2
2+
refs/heads/master: e99feabf47351a461518760e6f5f5086e11e7c17

trunk/src/lib/sha1.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ state type sha1 = state obj {
1919
// until reset is called
2020
fn result() -> vec[u8];
2121

22+
// Same as above, just a hex-string version.
23+
fn result_str() -> str;
24+
2225
// Reset the sha1 state for reuse. This is called
2326
// automatically during construction
2427
fn reset();
@@ -259,6 +262,15 @@ fn mk_sha1() -> sha1 {
259262
fn result() -> vec[u8] {
260263
ret mk_result(st);
261264
}
265+
266+
fn result_str() -> str {
267+
auto r = mk_result(st);
268+
auto s = "";
269+
for (u8 b in r) {
270+
s += _uint.to_str(b as uint, 16u);
271+
}
272+
ret s;
273+
}
262274
}
263275

264276
auto st = rec(h = _vec.init_elt_mut[u32](0u32, digest_buf_len),

0 commit comments

Comments
 (0)