SHA1

Struct SHA1 

pub struct SHA1 { /* private fields */ }
Available on crate features hash and insecure_sha1 only.
Expand description

安全散列算法1流式计算器(Secure Hash Algorithm 1 Stream Mode Calculator)

安全散列算法1是一种密码杂凑算法,美国国家安全局设计,并由美国国家标准技术研究所发布为联邦资料处理标准。
In cryptography, SHA-1 (Secure Hash Algorithm 1) is a hash function which was designed by the United States National Security Agency, and is a U.S. Federal Information Processing Standard.

SHA-1可以生成一个被称为消息摘要的160位(20字节)杂凑值,杂凑值通常的呈现形式为40个十六进制数。
It takes an input and produces a 160-bit (20-byte) hash value known as a message digest - typically rendered as 40 hexadecimal digits.

§示例(Examples)

use neuedu_cryptos::hashs::{HashImpl, SHA1};

const MESSAGE: [u8; 3] = [
    0x61, 0x62, 0x63,
];

let mut instance = SHA1::default();
instance.update(&MESSAGE)?;
let digest = instance.r#final()?;

assert_eq!(digest, [
    0xA9, 0x99, 0x3E, 0x36, 0x47, 0x06, 0x81, 0x6A,
    0xBA, 0x3E, 0x25, 0x71, 0x78, 0x50, 0xC2, 0x6C,
    0x9C, 0xD0, 0xD8, 0x9D,
]);

Trait Implementations§

§

impl Default for SHA1

§

fn default() -> Self

Returns the “default value” for a type. Read more
§

impl HashImpl for SHA1

§

fn block_size(&self) -> usize

块长度:64字节。
Block size: 64 Bytes.

§

fn output_size(&self) -> usize

输出长度:20字节。
Output size: 20 Bytes.

§

fn update(&mut self, message: &[u8]) -> Result<(), Error>

填入任意长度的待计算的消息。
Feed a message of any length to be calculated. Read more
§

fn final(&mut self) -> Result<Vec<u8>, Error>

结束填入待计算的消息。
End feeding in messages to be calculated.

Auto Trait Implementations§

§

impl Freeze for SHA1

§

impl RefUnwindSafe for SHA1

§

impl Send for SHA1

§

impl Sync for SHA1

§

impl Unpin for SHA1

§

impl UnwindSafe for SHA1

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.