aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGraydon Hoare <[email protected]>2011-03-26 17:36:08 -0700
committerGraydon Hoare <[email protected]>2011-03-26 17:36:08 -0700
commite99feabf47351a461518760e6f5f5086e11e7c17 (patch)
treef50af696d3f3432d5237654445face3543268ce4 /src
parentTeach creader and metadata writer how to do ty.ty_type. (diff)
downloadrust-e99feabf47351a461518760e6f5f5086e11e7c17.tar.xz
rust-e99feabf47351a461518760e6f5f5086e11e7c17.zip
Add a result_str method to std.sha1.sha1.
Diffstat (limited to 'src')
-rw-r--r--src/lib/sha1.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/lib/sha1.rs b/src/lib/sha1.rs
index b2294a3c..3899dddb 100644
--- a/src/lib/sha1.rs
+++ b/src/lib/sha1.rs
@@ -19,6 +19,9 @@ state type sha1 = state obj {
// until reset is called
fn result() -> vec[u8];
+ // Same as above, just a hex-string version.
+ fn result_str() -> str;
+
// Reset the sha1 state for reuse. This is called
// automatically during construction
fn reset();
@@ -259,6 +262,15 @@ fn mk_sha1() -> sha1 {
fn result() -> vec[u8] {
ret mk_result(st);
}
+
+ fn result_str() -> str {
+ auto r = mk_result(st);
+ auto s = "";
+ for (u8 b in r) {
+ s += _uint.to_str(b as uint, 16u);
+ }
+ ret s;
+ }
}
auto st = rec(h = _vec.init_elt_mut[u32](0u32, digest_buf_len),