# Struct mostinefficientsha::sha::Sha256
[−]
[src]

pub struct Sha256 { pub data: Vec<U>, pub input_data_len_in_bits: usize, pub digest: Vec<U>, }

This struct does a lazy SHA-256 hash calculation with fuzzy `f64`

bits.
It first creates a tree
of thouthands of `Term`

s that represent the bitwise calculations needed to
calculate the final hash. It then calculates that hash by evaluating the
`Term`

s that represent the bits of the final 256 bit hash value.

It can do this evaluation to `f64`

fuzzy bits or to a
`[8;u32]`

or ascii representation of the hash by rounding the `f64`

s.

The input data is made of `Symbol`

type `Term`

s, that have to be set before
evaluation.

## Fields

`data: Vec<U>`

The original input data. Some of the trailing bits may have been replaced. See `new()`

.

`input_data_len_in_bits: usize`

`digest: Vec<U>`

The final tree structure is hidden here.

## Methods

`impl Sha256`

[src]

`fn new(data: Vec<U>, len_message_in_last_u_in_bits: usize) -> Sha256`

Create a new tree of `Term`

s, that lazily calculates the SHA-256 hash of `data`

.

`len_message_in_last_u_in_bits`

is the number of bits in `data.last()`

that
are part of the input data. All following bits in `data.last()`

will be
ignored (and replaced).

You can access `data`

afterwards using the `data`

field.

This function just does SHA-256, but with `U`

s instead of `u32`

s.

`fn reset(&self)`

Resets the cache of all `RTerms`

within the `Term`

tree.

`fn eval_to_u32(&self) -> ArrayVec<[u32; 8]>`

Evaluates the digest/hash result into `u32`

s by rounding the `f64`

bits.

`fn hex(&self) -> String`

Evaluates the digest/hash result into its ascii hash representation
by rounding the `f64`

bits.

`fn evaluate(&self) -> Vec<f64>`

Evaluates the digest/hash results into 256 `f64`

s.

returnval[0] is the MSBit of the first byte. The first byte corresponds to the start of the ascii hash representation.

`fn nr_of_terms(&self) -> usize`

Returns the number of `Term`

s that were created to represent this
instance of the SHA-256 algorithm. The number depends heavily on the
length of the input data.

`fn nr_of_terms_flattened(&self) -> usize`

Returns the number of `Term`

s that would make the flattened version
of the tree of each bit of the digest.

`fn max_logic_depth_and_max_stack_size(&self) -> (usize, usize)`

Max stack size needed when evaluating each bit of the digest recursively.

It also returns the maximum logic depth.

Returns: (max_logic_depth, max_stacksize)

`fn statistics(&self) -> String`

Returns a String describing the statistics. Same as debug print.