1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
//! Utility functions for statistical tests
//!
//! This module provides common utility functions used by various statistical tests.
/// Converts a string to a vector of numeric values representing characters
///
/// # Arguments
///
/// * `text` - The input text to convert
///
/// # Returns
///
/// A vector of numeric values where:
/// - A-Z are represented as 0-25
/// - '#' is represented as 26
/// - 0-9 are represented as 27-36
///
/// Characters not in the cipher_symbols set are ignored.
///
/// # Examples
///
/// ```
/// use cipher_identifier::statistical_tests::utils::convert_string;
///
/// let result = convert_string("ABC123");
/// assert_eq!(result, vec![0, 1, 2, 28, 29, 30]);
/// ```
/// Checks if the data contains digits (characters with values > 26)
///
/// # Arguments
///
/// * `data` - Vector of numeric values representing characters
///
/// # Returns
///
/// "Y" if the data contains digits, "N" otherwise
///
/// # Examples
///
/// ```
/// use cipher_identifier::statistical_tests::utils::has_digits;
///
/// let data = vec![0, 1, 2, 30]; // Contains 30 which is > 26
/// assert_eq!(has_digits(&data), "Y");
///
/// let data = vec![0, 1, 2, 25]; // No values > 26
/// assert_eq!(has_digits(&data), "N");
/// ```
/// Checks if the data contains the hash symbol (character with value 26)
///
/// # Arguments
///
/// * `data` - Vector of numeric values representing characters
///
/// # Returns
///
/// "Y" if the data contains the hash symbol, "N" otherwise
///
/// # Examples
///
/// ```
/// use cipher_identifier::statistical_tests::utils::has_hash;
///
/// let data = vec![0, 1, 26, 2]; // Contains 26 which represents '#'
/// assert_eq!(has_hash(&data), "Y");
///
/// let data = vec![0, 1, 2, 25]; // No value 26
/// assert_eq!(has_hash(&data), "N");
/// ```