wtx 0.44.3

A collection of different transport implementations and related tools focused primarily on web technologies.
Documentation
use crate::crypto::{Hash, Sha256DigestRustCrypto, Sha384DigestRustCrypto};
use sha2::Digest;

impl Hash for Sha256DigestRustCrypto {
  type Digest = [u8; 32];

  #[inline]
  fn digest<'data>(data: impl IntoIterator<Item = &'data [u8]>) -> Self::Digest {
    let mut ctx = <sha2::Sha256 as Digest>::new();
    for elem in data {
      ctx.update(elem);
    }
    ctx.finalize().into()
  }
}

impl Hash for Sha384DigestRustCrypto {
  type Digest = [u8; 48];

  #[inline]
  fn digest<'data>(data: impl IntoIterator<Item = &'data [u8]>) -> Self::Digest {
    let mut ctx = <sha2::Sha384 as Digest>::new();
    for elem in data {
      ctx.update(elem);
    }
    ctx.finalize().into()
  }
}