pub struct HashFunction { /* fields omitted */ }
Create a new hash function
Will fail if the named hash is not known
assert!(botan::HashFunction::new("SHA-256").is_ok());
assert!(botan::HashFunction::new("Hash9000").is_err());
Return the name of this algorithm which may or may not exactly
match what was provided to new()
let hash = botan::HashFunction::new("SHA-384").unwrap();
assert_eq!(hash.algo_name().unwrap(), "SHA-384");
Return the output length of the hash function, in bytes
let hash = botan::HashFunction::new("SHA-256").unwrap();
assert_eq!(hash.output_length().unwrap(), 32);
Return the block length of the hash function, in bytes
let hash = botan::HashFunction::new("SHA-256").unwrap();
assert_eq!(hash.block_size().unwrap(), 64);
Add data to a hash computation, may be called many times
let hash = botan::HashFunction::new("SHA-256").unwrap();
hash.update(&[1,2,3]).unwrap();
hash.update(&[4,5,6]).unwrap();
Finalize the computation, returning the hash of the message
let hash = botan::HashFunction::new("SHA-256").unwrap();
hash.update(&[1,2,3]).unwrap();
hash.update(&[4,5,6]).unwrap();
let digest = hash.finish().unwrap();
Clear the internal state of the hash function. It acts as if it
was newly created, and is ready to compute a new digest.
Basically the same as calling final, but without returning a
result.
Copy hash object state to a new object, allowing prefixes of
messages to be hashed. This function is also called by clone.
Should not fail but might due to unexpected error
let hash = botan::HashFunction::new("SHA-256").unwrap();
hash.update(&[1,2,3]);
let hash2 = hash.duplicate().unwrap();
hash2.update(&[4,5,6]);
let result1 = hash.finish().unwrap();
let result2 = hash2.finish().unwrap();
Formats the value using the given formatter. Read more
Performs copy-assignment from source
. Read more
Executes the destructor for this type. Read more