use super::{CryptographicHashImpl, SM3};


/// SM3密码杂凑算法块式计算器（SM3 Cryptographic Hash Calculation (Block Mode) Calculator）
///
/// # 参数（Arguments）
///
/// * message - 消息（Message）
///
/// # 示例（Examples）
///
/// ```rust
/// # fn main() -> Result<(), ()> {
/// use neuedu_cryptos::cryptographic_hashs::sm3;
///
/// let digest = sm3(b"abc")?;
///
/// assert_eq!(digest, [
///     0x66, 0xC7, 0xF0, 0xF4, 0x62, 0xEE, 0xED, 0xD9,
///     0xD1, 0xF2, 0xD4, 0x6B, 0xDC, 0x10, 0xE4, 0xE2,
///     0x41, 0x67, 0xC4, 0x87, 0x5C, 0xF2, 0xF7, 0xA2,
///     0x29, 0x7D, 0xA0, 0x2B, 0x8F, 0x4B, 0xA8, 0xE0,
/// ]);
/// #
/// #     Ok(())
/// # }
/// ```
pub fn sm3(message: &[u8]) -> Result<[u8; 32], ()> {
    let mut instance = SM3::default();
    instance.update(message).unwrap();

    Ok(instance.r#final().unwrap().try_into().unwrap())
}
