Extras

Bruteforce

Combinations

chepy.extras.combinatons.generate_combo(words: List[Any], min_length: int = 0, max_length: Optional[int] = None, join_by: Optional[str] = None) Iterator[tuple]

Creates all possible combinations from the words being passed. Returns a generator. length controls the length of the permutations.

Parameters
  • words (List[Any]) – List of strings.

  • min_length (int, optional) – Minimum length of permutations. By default, 0 which will generate all

  • max_length (int, optional) – Maximum length of permutations. By default, it is the length of the words list

Returns

A generator containing tuples of combinations

Return type

Iterator[tuple]

chepy.extras.combinatons.hex_chars() list

Returns an array of all the hex characters

Returns

List of all hex characters

Return type

list

Crypto

Misc

chepy.extras.misc.index_of_coincidence(data: Any) float

Index of Coincidence (IC) is the probability of two randomly selected characters being the same.

  • 0 represents complete randomness (all characters are unique), whereas 1 represents no randomness (all characters are identical).

  • English text generally has an IC of between 0.67 to 0.78.

  • ‘Random’ text is determined by the probability that each letter occurs the same number of times as another.

Reference

Parameters

data (Any) – Any data type

Returns

IC as float

Return type

float

chepy.extras.misc.shannon_entropy(data: Any, unit='shannon') float

Calculate the Shannon entropy of any data type. Units could be natural, shannon or hartley

  • 0 represents no randomness (i.e. all the bytes in the data have the same value)

    whereas 8, the maximum, represents a completely random string.

  • Standard English text usually falls somewhere between 3.5 and 5.

  • Properly encrypted or compressed data of a reasonable length should have an entropy of over 7.5.

Parameters
  • data (Any) – Any data type

  • unit (str, optional) – Unit type. Defaults to “shannon”.

Returns

Calculated entropy

Return type

float