Advertisement
Guest User

Untitled

a guest
May 29th, 2015
289
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. pub fn multihash(wanthash: hashtypes, input: Vec<u8>) -> Result<Vec<u8>, String> {
  2. let ssl_hash: Option<Type> = match wanthash {
  3. hashtypes::sha1 => Some(Type::SHA1),
  4. hashtypes::sha2_256 => Some(Type::SHA256),
  5. hashtypes::sha2_512 => Some(Type::SHA512),
  6. _ => None,
  7. };
  8. match ssl_hash {
  9. Some(openssl_type) => Ok(hash(openssl_type, input.as_slice()).insert(0, wanthash.to_u8())), // Add the hashtype to the hash.
  10. None => Err("Sorry, we don't support that hash algorithm yet."),
  11. };
  12. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement