| |
- builtins.object
-
- ViginereBreaker
class ViginereBreaker(builtins.object) |
|
ViginereBreaker(data: collections.abc.Iterable, key_length: int = None, statistics: Dict[Any, float] = {'E': 13, 'A': 8}, alphabet: collections.abc.Iterable = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')
This class breaks viginere cipher.
data: should be str or bytes (it can be Iterable[Any]).
key_length: should be the key length if you know the key length else None
statistics: should be the dictionnary of pourcent of decipher data (for exemple if data is English text statistics should be: {"E": 13, "A": 8})
alphabet: characters to decipher (for example "ABCDEFGHIJKLMNOPQRSTUVWXYZ")
>>> c = ViginereBreaker("E" * 13 + "A" * 8 + "Z" * 79)
>>> c.breaker()
[['A']] |
|
Methods defined here:
- __init__(self, data: collections.abc.Iterable, key_length: int = None, statistics: Dict[Any, float] = {'E': 13, 'A': 8}, alphabet: collections.abc.Iterable = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')
- Initialize self. See help(type(self)) for accurate signature.
- breaker(self) -> collections.abc.Iterable
- This function break viginere cipher.
>>> c = ViginereBreaker("E" * 13 + "A" * 8 + "Z" * 79)
>>> c.breaker()
[['A']]
>>> c = ViginereBreaker("E" * 13 + "A" * 8 + "Z" * 79, 0)
>>> c.breaker()
[['A']]
Static methods defined here:
- found_chars_keys(data: collections.abc.Iterable, key_length: int, statistics: Dict[Any, Any], alphabet: collections.abc.Iterable) -> collections.abc.Iterable
- This function search the key.
>>> ViginereBreaker.found_chars_keys("E" * 13 + "A" * 8 + "Z" * 79, 0, {"E": 13, "A": 8}, ascii_uppercase)
[['A']]
- get_statistics(counter: collections.Counter, alphabet: collections.abc.Iterable) -> Dict[Any, int]
- This function return character statistics.
>>> ViginereBreaker.get_statistics({"A": 1}, "A")
{"A": 100}
- match(counter: collections.Counter, char: Any, values: Tuple[int, int]) -> bool
- This function check if character statistic match.
>>> ViginereBreaker.match({"A": 100}, "A", (100, 100))
True
>>> ViginereBreaker.match({"A": 100}, "A", (0, 99))
False
- match_characters(counter: collections.Counter, statistics: Dict[Any, Tuple[int, int]], alphabet: collections.abc.Iterable, index: int, alphabet_length: int) -> bool
- This function match any statistic characters.
>>> ViginereBreaker.match_characters({"A": 100}, {"A": (100, 100)}, ascii_uppercase, 0, 26)
True
>>> ViginereBreaker.match_characters({"A": 100}, {"A": (0, 99)}, ascii_uppercase, 0, 26)
False
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
| |