libenigma
Enigma machine utility library
Loading...
Searching...
No Matches
ngram.h File Reference
#include "crack.h"

Go to the source code of this file.

Macros

#define ENIGMA_BIIDX(a, b)   ((a << 5) | b)
 Generate a bigram index from two characters (for array lookup)
 
#define ENIGMA_TRIIDX(a, b, c)   ((a << 10) | (b << 5) | c)
 Generate a trigram index from three characters (for array lookup)
 
#define ENIGMA_QUADIDX(a, b, c, d)   ((a << 15) | (b << 10) | (c << 5) | d)
 Generate a quadgram index from four characters (for array lookup)
 

Functions

float enigma_bigram_score (const EnigmaCrackParams *, const char *)
 Score text using bigram frequencies.
 
float enigma_trigram_score (const EnigmaCrackParams *, const char *)
 Score text using trigram frequencies.
 
float enigma_quadgram_score (const EnigmaCrackParams *, const char *)
 Score text using quadgram frequencies.
 

Detailed Description

This file declares functions for cracking Enigma configurations using n-gram scoring.

Macro Definition Documentation

◆ ENIGMA_BIIDX

#define ENIGMA_BIIDX (   a,
 
)    ((a << 5) | b)

Generate a bigram index from two characters (for array lookup)

◆ ENIGMA_QUADIDX

#define ENIGMA_QUADIDX (   a,
  b,
  c,
 
)    ((a << 15) | (b << 10) | (c << 5) | d)

Generate a quadgram index from four characters (for array lookup)

◆ ENIGMA_TRIIDX

#define ENIGMA_TRIIDX (   a,
  b,
 
)    ((a << 10) | (b << 5) | c)

Generate a trigram index from three characters (for array lookup)

Function Documentation

◆ enigma_bigram_score()

float enigma_bigram_score ( const EnigmaCrackParams cfg,
const char *  text 
)

Score text using bigram frequencies.

Parameters
cfgPointer to the cracking configuration structure.
textThe text to score.
Returns
The total bigram score.

◆ enigma_quadgram_score()

float enigma_quadgram_score ( const EnigmaCrackParams cfg,
const char *  text 
)

Score text using quadgram frequencies.

Parameters
cfgPointer to the cracking configuration structure.
textThe text to score.
Returns
The total quadgram score.

◆ enigma_trigram_score()

float enigma_trigram_score ( const EnigmaCrackParams cfg,
const char *  text 
)

Score text using trigram frequencies.

Parameters
cfgPointer to the cracking configuration structure.
textThe text to score.
Returns
The total trigram score.