aboutsummaryrefslogtreecommitdiff
path: root/hash.rs
diff options
context:
space:
mode:
authorErick Tryzelaar <[email protected]>2012-04-20 09:47:46 -0700
committerErick Tryzelaar <[email protected]>2012-04-20 09:47:46 -0700
commitcd4e72dc98a19cda905c8c40c97b6491e4747b49 (patch)
treeabcf4723f1c49b3064b063d2d36ac39c0483d483 /hash.rs
parentUpdate for 0.2 (diff)
downloadrust-openssl-cd4e72dc98a19cda905c8c40c97b6491e4747b49.tar.xz
rust-openssl-cd4e72dc98a19cda905c8c40c97b6491e4747b49.zip
Modernize crypto with new rust style and rustdoc support
Diffstat (limited to 'hash.rs')
-rw-r--r--hash.rs35
1 files changed, 8 insertions, 27 deletions
diff --git a/hash.rs b/hash.rs
index 4ba64e0b..a68347c7 100644
--- a/hash.rs
+++ b/hash.rs
@@ -1,40 +1,23 @@
-use std;
-
-import core::ptr;
-import core::str;
-import core::vec;
-
import libc::c_uint;
export hasher;
export hashtype;
-export mk_hasher;
export hash;
export _native;
export md5, sha1, sha224, sha256, sha384, sha512;
iface hasher {
- /*
- Method: init
-
- Initializes this hasher
- */
+ #[doc = "Initializes this hasher"]
fn init();
- /*
- Method: update
-
- Update this hasher with more input bytes
- */
+ #[doc = "Update this hasher with more input bytes"]
fn update([u8]);
- /*
- Method: final
-
+ #[doc = "
Return the digest of all bytes added to this hasher since its last
initialization
- */
+ "]
fn final() -> [u8];
}
@@ -78,7 +61,7 @@ fn evpmd(t: hashtype) -> (EVP_MD, uint) {
}
}
-fn mk_hasher(ht: hashtype) -> hasher {
+fn hasher(ht: hashtype) -> hasher {
type hasherstate = {
evp: EVP_MD,
ctx: EVP_MD_CTX,
@@ -111,13 +94,11 @@ fn mk_hasher(ht: hashtype) -> hasher {
ret h;
}
-/*
-Function: hash
-
+#[doc = "
Hashes the supplied input data using hash t, returning the resulting hash value
-*/
+"]
fn hash(t: hashtype, data: [u8]) -> [u8] unsafe {
- let h = mk_hasher(t);
+ let h = hasher(t);
h.init();
h.update(data);
ret h.final();