Module classic_crypto::util[][src]

Expand description

Contains functions that are used across the library

Modules

prime_gen

Functions

blocks

Remove all whitespace then seperate each block of block_size chars by sep

extended_gcd

Performs the extended euclidean algorithm on a and b.

fill_alphabet_continue

Returns a vector of size alphabet_size containing all the values in the range 0..alphabet_size, keyed by the slice key.

fill_alphabet_from_start

Returns a vector of size alphabet_size containing all the values in the range 0..alphabet_size, keyed by the slice key.

fill_consecutive_vec

Fills a Vec with values incremented by 1 each time, starting from start. Each value is calculated as value % modulus.

fill_random_array

Fills a Vec with values incremented by 1 each time, starting from start. Each value is calculated as value % modulus.

find_order

Generates a permutation of the range 0..arr.len() sorted in the same order as arr, representing the current permutation in index form.

gcd

Calculates the greatest common divisor (gcd) of a and b.

invert

Inverts a substitution alphabet (a &[i16] containing each of the elements 0..arr.len()), so that each element can be indexed in O(1) time. i.e. transforms arr[idx] = value to arr[value] = idx.

is_unique

Returns true if the string contains any repeated characters

mmi

Calculates the modular multiplicative inverse (mmi) of a modulo b. mmi satisfies (a * mmi) % b == 1. Returns None if there is no solution.

modulo

Performs the modulo operation, but ensures a positive result, so that it functions for negative numbers by wrapping around the modulus b.

shuffle

Shuffles the elements of a vector