pub struct PossiblePlaintext(/* private fields */);
Expand description
A possible plaintext. The PossiblePlaintext
struct provides utilities for analyzing
and scoring texts that may be plaintexts. This is useful for brute-forcing ciphers, when
you need a system to find the decryption outputs that are most likely to be correct.
Implementations§
Source§impl PossiblePlaintext
impl PossiblePlaintext
Sourcepub fn score(&self) -> f64
pub fn score(&self) -> f64
Returns the “score” of this plaintext. The score is based on cryptographic analysis, and a higher score indicates a better plaintext. The score is calculated from:
- Index of coincidence
- Monogram Frequency
- Bigram Frequency
- Trigram Frequency
- Quadram Frequency
Sourcepub fn text(&self) -> &str
pub fn text(&self) -> &str
Returns the original text of this plaintext.
§Returns
A reference to the stored text in this plaintext.
Sourcepub fn best_n<T: AsRef<str>>(plaintexts: &[T], n: usize) -> Result<Vec<String>>
pub fn best_n<T: AsRef<str>>(plaintexts: &[T], n: usize) -> Result<Vec<String>>
Returns the most top n
plaintexts in order from best to worst based on cryptographic analysis. To get only the
best one, use Plaintext::best
.
§Parameters
plaintexts
- The plaintexts to find the best ofn
- The number of best plaintexts to return
§Returns
The n
best plaintexts in order from best to worst.
§Errors
If the given n
is greater than the number of plaintexts (or 0), or if the given plaintext slice is empty.
Trait Implementations§
Source§impl Clone for PossiblePlaintext
impl Clone for PossiblePlaintext
Source§fn clone(&self) -> PossiblePlaintext
fn clone(&self) -> PossiblePlaintext
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for PossiblePlaintext
impl Debug for PossiblePlaintext
Source§impl Hash for PossiblePlaintext
impl Hash for PossiblePlaintext
Source§impl Ord for PossiblePlaintext
impl Ord for PossiblePlaintext
Source§impl PartialEq for PossiblePlaintext
impl PartialEq for PossiblePlaintext
Source§impl PartialOrd for PossiblePlaintext
impl PartialOrd for PossiblePlaintext
impl Eq for PossiblePlaintext
impl StructuralPartialEq for PossiblePlaintext
Auto Trait Implementations§
impl Freeze for PossiblePlaintext
impl RefUnwindSafe for PossiblePlaintext
impl Send for PossiblePlaintext
impl Sync for PossiblePlaintext
impl Unpin for PossiblePlaintext
impl UnwindSafe for PossiblePlaintext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more