use super::{CryptographicHashImpl, SHA1};


/// 安全散列算法1（SHA-1）块式计算器（Secure Hash Algorithm 1 (SHA-1) Block Mode Calculator）
///
/// # 参数（Arguments）
///
/// * message - 消息（Message）
///
/// # 示例（Examples）
///
/// ```rust
/// # fn main() -> Result<(), ()> {
/// use neuedu_cryptos::cryptographic_hashs::sha1;
///
/// let digest = sha1(b"abc")?;
///
/// assert_eq!(digest, [
///     0xA9, 0x99, 0x3E, 0x36, 0x47, 0x06, 0x81, 0x6A,
///     0xBA, 0x3E, 0x25, 0x71, 0x78, 0x50, 0xC2, 0x6C,
///     0x9C, 0xD0, 0xD8, 0x9D,
/// ]);
/// #
/// #     Ok(())
/// # }
/// ```
pub fn sha1(message: &[u8]) -> Result<[u8; 20], ()> {
    let mut instance = SHA1::default();
    instance.update(message).unwrap();

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