-
Notifications
You must be signed in to change notification settings - Fork 0
/
kasiski.h
39 lines (25 loc) · 909 Bytes
/
kasiski.h
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
#ifndef KASISKI_H__
#define KASISKI_H__
/*
* This module perform a Kasiski analysis on a given text.
* A Kasiski analysis is a kind of discreet autocorrelation on a text.
* It consist in comparing the text with a copy of itself shifted by a given
* offset. And then the comparison is done by counting the substring that match.
*/
#include <sys/types.h>
struct kasiski {
const char *str;
size_t str_len;
size_t minlen;
/* ka_analyze will fill this array so that score[klen] is the number of
* substring of str that has been found at n*klen distance. */
size_t *score;
};
/* Initialize a kasiski structure. minlen is the minimal length of the
* substrings to match. */
void ka_init(struct kasiski *k, const char *str, size_t minlen);
/* Deinitialize a kasiski structure. */
void ka_fini(struct kasiski *k);
/* Perform a Kasiski analysis. */
void ka_analyze(struct kasiski *k);
#endif