Function get_ioc

Source
pub fn get_ioc(text: &str) -> f64
Expand description

Calculates the Index of Coincidence (IoC) for the given text

The Index of Coincidence is a measure of the probability that two randomly selected characters from the text are the same. It’s useful for distinguishing between different types of ciphers.

§Arguments

  • text - The input text to analyze

§Returns

The Index of Coincidence multiplied by 1000

§Examples

use cipher_identifier::statistical_tests::ioc::get_ioc;

let text = "HELLOWORLD";
let ioc = get_ioc(text);
assert!(ioc > 0.0);