Main Page | Namespace List | Data Structures | File List | Data Fields | Globals

nzNema Class Reference

Simulation of the Swiss Army NeMa cipher machine (1947). More...

#include <nema.h>


Public Member Functions

 nzNema ()
 default constructor
 nzNema (string passwd)
 constructor with 10-letter password
string crypt (string strIn)
 encrypt or decrypt a string
string crypt (nzCipherText ctext)
 encrypt or decrypt a ciphertext string
double fastCrypt (string strIn)
 fast (no output) encryption of a string. Returns english-chi2.
double fastCrypt (nzCipherText ctext)
 fast (no output) encryption of a ciphertext string
bool kpta (const string strPlain, const string strCipher)
 known-plaintext attack, returns true if key is correct (set key first)
void initState (int init[10])
 set 10-letter password passing array of alphabetical codes [0-25]
void initState (string passwd)
 set 10-letter password passing a string
double getUniformChi2 ()
 return uniform-random-chi2 of ciphertext

Private Member Functions

char flow (char charIn)
 current flow from keyboard to lamps, through the wheels
void stepState ()
 step the rotor wheels after a keystroke
void printState ()
 show current 10-letter password
void setInnerKey ()
 set inner key (contact wheels and notch rings, from right to left!)
int getWheelOffset (int wheel)
 relative positions of two adjacent contact wheels

Private Attributes

int state [10]
 positions of the 10 rotor wheels
int steps
 number of keystrokes
const int * notchRings [6]
 inner key: list of notch rings
const int * rotors [4]
 inner key: list of contact wheels
const int * invrot [4]
 inner key: list of contact wheels (for backwards flow)
nzCipherText cipher
 container for encrypted text


Detailed Description

Simulation of the Swiss Army NeMa cipher machine (1947).


Constructor & Destructor Documentation

nzNema::nzNema  ) 
 

default constructor

nzNema::nzNema string  passwd  ) 
 

constructor with 10-letter password


Member Function Documentation

string nzNema::crypt nzCipherText  ctext  )  [inline]
 

encrypt or decrypt a ciphertext string

string nzNema::crypt string  strIn  ) 
 

encrypt or decrypt a string

double nzNema::fastCrypt nzCipherText  ctext  )  [inline]
 

fast (no output) encryption of a ciphertext string

double nzNema::fastCrypt string  strIn  ) 
 

fast (no output) encryption of a string. Returns english-chi2.

char nzNema::flow char  charIn  )  [private]
 

current flow from keyboard to lamps, through the wheels

double nzNema::getUniformChi2  )  [inline]
 

return uniform-random-chi2 of ciphertext

int nzNema::getWheelOffset int  wheel  )  [private]
 

relative positions of two adjacent contact wheels

void nzNema::initState string  passwd  ) 
 

set 10-letter password passing a string

void nzNema::initState int  init[10]  ) 
 

set 10-letter password passing array of alphabetical codes [0-25]

bool nzNema::kpta const string  strPlain,
const string  strCipher
 

known-plaintext attack, returns true if key is correct (set key first)

void nzNema::printState  )  [private]
 

show current 10-letter password

void nzNema::setInnerKey  )  [private]
 

set inner key (contact wheels and notch rings, from right to left!)

void nzNema::stepState  )  [private]
 

step the rotor wheels after a keystroke


Field Documentation

nzCipherText nzNema::cipher [private]
 

container for encrypted text

const int* nzNema::invrot[4] [private]
 

inner key: list of contact wheels (for backwards flow)

const int* nzNema::notchRings[6] [private]
 

inner key: list of notch rings

const int* nzNema::rotors[4] [private]
 

inner key: list of contact wheels

int nzNema::state[10] [private]
 

positions of the 10 rotor wheels

int nzNema::steps [private]
 

number of keystrokes


The documentation for this class was generated from the following files: