PolygraphiaIIICipherGenerator Class Reference

Inheritance diagram for PolygraphiaIIICipherGenerator:
Collaboration diagram for PolygraphiaIIICipherGenerator:

List of all members.


Detailed Description

Class to generate ciphers based on Trithemius Polygraphia I, II & III substitution. It substitutes randomly from the underlying substitution list, contrary to PolygraphiaICipherGenerator witch substitutes in the order of the list. This substitution method is (for the case of P I & II) also known as "Ave Maria Cipher"

Author:
jhermes

Public Types

enum  EncipherMethod {
  ATBASH = ("de.uni_koeln.spinfo.cryptology.cryptanalysis.ciphergenerators.AtbashCipherGenerator"), GEMATRIA = ("de.uni_koeln.spinfo.cryptology.cryptanalysis.ciphergenerators.GematriaValueGenerator"), PLAYFAIR = ("de.uni_koeln.spinfo.cryptology.cryptanalysis.ciphergenerators.PlayfairCipherGenerator"), POLYBUS = ("de.uni_koeln.spinfo.cryptology.cryptanalysis.ciphergenerators.PolybusCipherGenerator"),
  CAESAR = ("de.uni_koeln.spinfo.cryptology.cryptanalysis.ciphergenerators.CaesarCipherGenerator"), VIGNERE = ("de.uni_koeln.spinfo.cryptology.cryptanalysis.ciphergenerators.VignereCipherGenerator"), POLYGRAPHIA_I = ("de.uni_koeln.spinfo.cryptology.steganalysis.ciphergenerators.PolygraphiaICipherGenerator"), POLYGRAPHIA_III = ("de.uni_koeln.spinfo.cryptology.steganalysis.ciphergenerators.PolygraphiaIIICipherGenerator"),
  POLYGRAPHIA_V = ("de.uni_koeln.spinfo.cryptology.cryptanalysis.ciphergenerators.PolygraphiaVCipherGenerator")
}
enum  ConfigurationElement {
  KEY = ("Key"), ALPHABET = ("Alphabet"), REPLACEMENTS = ("Replacements"), WORD_SUBSTITUTES = ("Substitutes"),
  DELETE_WHITESPACE = ("Whitespace deletion")
}

Public Methods

 PolygraphiaIIICipherGenerator (List< List< String >> substitutes)
 PolygraphiaIIICipherGenerator (List< List< String >> substitutes, char[] alphabet)
 PolygraphiaIIICipherGenerator (Map< Character, List< String >> substitutes)
 PolygraphiaIIICipherGenerator (Map< Character, List< String >> substitutes, Map< String, String > replacements)
 PolygraphiaIIICipherGenerator ()
void configure (Map< ConfigurationElement, String > configurations)
String encipher (String plainText)
String encipher (List< String > words)
String getAssembledString ()
Set< Character > getAlphabet ()
void setAlphabet (char[] alphabet)
String replaceAll (String toProcess)
Map< String, String > getReplacements ()
Map< String, String > getReplacements ()
Set< Character > getAlphabet ()

Public Static Methods

static String assembleSignificantLetters (List< String > words, int pos)
static String assembleSignificantLetters (List< String > words, List< Integer > positions)
static String getPlaintextFromTrithemianIncantation (List< String > words)
static String getPlaintextFromTrithemianSteganographianCipher (List< String > words, boolean[] significantSequence)
static char[] getDefaultAlphabet ()
static char[] getDefaultAlphabetWithoutChar (char ch)
static char[] getTrithemianAlphabet ()
static Map< String, String > trithemianAlphabetReplacements ()

Protected Methods

boolean checkSubstitutes (String substitutesString)
boolean checkAlphabet (String alphabetString, char[] defaultAlphabet)
boolean checkReplacements (String replacementString)
void checkWSDeletion (String deleteWhitespace)
boolean checkIntKey (String intKeyString, int defaultKey)
String getAlphabetAsStringKey (int start)

Protected Attributes

Map< Character, List< String > > wordSubstitutions
char[] alphabet
Map< String, String > replacementMap
int intKey
boolean deleteWhitespace
Logger logger = Logger.getLogger(this.getClass())

Package Attributes

Random random

Member Enumeration Documentation

enum ConfigurationElement [inherited]

Enumeration of potential configuration elements for Cryptologers.

Author:
jhermes
Enumerator:
KEY 
ALPHABET 
REPLACEMENTS 
WORD_SUBSTITUTES 
DELETE_WHITESPACE 
enum EncipherMethod [inherited]

Enumeration of encipher methods.

Author:
jhermes
Enumerator:
ATBASH 
GEMATRIA 
PLAYFAIR 
POLYBUS 
CAESAR 
VIGNERE 
POLYGRAPHIA_I 
POLYGRAPHIA_III 
POLYGRAPHIA_V 

Constructors

PolygraphiaIIICipherGenerator ( List< List< String >>  substitutes)

Generates a crypto-grapher based on the specified list of char-substitutions and the Trithemian alphabet (abcdefghiklmnopqrstuxyzw).

Parameters:
substitutesList of different substitutes lists. Each embedded list contains the substitutes for one character.
PolygraphiaIIICipherGenerator ( List< List< String >>  substitutes,
char[]  alphabet 
)

Generates a crypto-grapher based on the specified list of substitutions and alphabet. Note that ideally the size of the list corresponds to the size of the alphabet.

Parameters:
substitutesList of different substitutes lists. Each embedded list contains the substitutes for one character.
PolygraphiaIIICipherGenerator ( Map< Character, List< String >>  substitutes)

Generates a crypto-grapher based on the specified alphabet/substitutes map.

Parameters:
substitutesalphabet/substitutes map. Each list contains the different substitutions for the character.
PolygraphiaIIICipherGenerator ( Map< Character, List< String >>  substitutes,
Map< String, String >  replacements 
)

Generates a crypto-grapher based on the specified alphabet/substitutes map. If second parameter is true, some replacement operations will take place for each plain text: 'v' will be substituted by 'u', 'j' by 'i', 'ß' by 'ss', 'ä' by 'ae' etc.

Parameters:
substitutesalphabet/substitutes map. Each list contains the different substitutions for the character.

Generates a crypto-grapher that have to be configured afterwards by call the configure(Map<String,String> configurations) method.


Method Details

static String assembleSignificantLetters ( List< String >  words,
int  pos 
) [static, inherited]

Static method to assemble significant letters of the specified word List on a String. If the specified position lies outside a word, it will be ignored.

Parameters:
wordswords with significant letters.
posposition of significant letter of each word. Positive ints will be interpreted as position from start, negative from end of each word.
Returns:
String of assembled significant letters
static String assembleSignificantLetters ( List< String >  words,
List< Integer >  positions 
) [static, inherited]

Static method to assemble significant letters of the specified word List on a String. Letters will be assembled in order of the specified positions. Positive position Integers will be interpreted as position from start, negative as positions from end of each word. Example: If the Integer List contains {3,-1,4} the significant letter order of the word "trithemius" will be "ist". If one of the specified positions lies outside a word, it will be ignored.

Parameters:
wordswords with significant letters.
positionsof significant letters of each word.
Returns:
String of assembled significant letters
boolean checkAlphabet ( String  alphabetString,
char[]  defaultAlphabet 
) [protected, inherited]

Builds alphabet from specified string, if not null and not empty. Else the specified default alphabet will be set as alphabet.

Parameters:
alphabetStringString to set as alphabet.
defaultAlphabetdefault alphabet.
Returns:
true, if alphabetString can be set as alphabet, false if default alphabet is set.
boolean checkIntKey ( String  intKeyString,
int  defaultKey 
) [protected, inherited]

Builds an integer key from the specified string.

Parameters:
intKeyStringinteger key as string
defaultKeykey to set if integer key could not be build from specified string.
Returns:
true, if int key is builded from specified string, false otherwise.
boolean checkReplacements ( String  replacementString) [protected, inherited]

Builds replacement map from specified string that should be parsable CSV data.

Parameters:
replacementStringreplacements as csv data.
Returns:
true, if replacement map could be build, false otherwise.
boolean checkSubstitutes ( String  substitutesString) [protected, inherited]

Builds the word substitution map using specified string. String must contain parsable csv data.

Parameters:
substitutesStringcsv substitute data
Returns:
true, if word substitution map have been build, false otherwise.

Reimplemented in PolygraphiaICipherAnalyzer.

void checkWSDeletion ( String  deleteWhitespace) [protected, inherited]

If specified string equals true, whitespace will be deleted in the substituted text.

Parameters:
deleteWhitespaceboolean value as string
void configure ( Map< ConfigurationElement, String >  configurations)

Configures the crypto-grapher by the specified configurations. Must be called if this is generated by the non-argument-constructor.

Parameters:
configurations

Implements Cryptologer.

String encipher ( String  plainText)

Enciphers the specified text.

Parameters:
plainTexttext to encipher.
Returns:
enciphered text.

Implements Encipherer.

String encipher ( List< String >  words)

Returns the cipher text of the specified cipher word sequence. Some methods (eg. Playfair) delete white spaces.

Parameters:
wordsSequence of words to encipher.
Returns:
cipher text.

Implements Encipherer.

Set<Character> getAlphabet ( ) [inherited]

Returns the alphabet of this crypto component.

Returns:
alphabet of this crypto component.
Set<Character> getAlphabet ( ) [inherited]

Returns a set of the alphabet of replacement characters

Returns:
String getAlphabetAsStringKey ( int  start) [protected, inherited]

Returns the alphabet as string key (starts from the specified position, e.g. 1 for a).

Parameters:
startPosition of the alphabet to start.
Returns:
alphabet as string key.
String getAssembledString ( ) [inherited]

Assembles the significant letters of the specified word.

Parameters:
wordto assemble. Returns the assembled plaintext String.
Returns:
assembled plaintext String.
static char [] getDefaultAlphabet ( ) [static, inherited]

Returns the default alphabet (a-z), lower case letters.

Returns:
default alphabet (a-z).
static char [] getDefaultAlphabetWithoutChar ( char  ch) [static, inherited]

Returns the default alphabet (a-z) without the specified character. Needed e.g. to get 25 letters for a 5 * 5 matrix.

Parameters:
chcharacter to ignore.
Returns:
default alphabet without the specified character.
static String getPlaintextFromTrithemianIncantation ( List< String >  words) [static, inherited]

Static method to get the plaintext from a Trithemian incantation of Steganographia I & II.

Parameters:
wordswords of an incantation
Returns:
plaintext from the specified incantation.
static String getPlaintextFromTrithemianSteganographianCipher ( List< String >  words,
boolean[]  significantSequence 
) [static, inherited]

Static method to get the plaintext from a Trithemian cipher of Steganographia I & II. Eg. if significantSequence is [true, true, false, false] after two significant words will be deleted two words, if "One Two Three Four Five Six Seven" is the input, "One Two Five Six" will be analyzed, the returned String will be "otfs".

Parameters:
wordswords of the cipher
significantSequencesequence of significant initial letters
Returns:
plaintext of the specified cipher
Map<String, String> getReplacements ( ) [inherited]

Returns a map of the replacements that were used by the component

Returns:
map of replacements
Map<String, String> getReplacements ( ) [inherited]
static char [] getTrithemianAlphabet ( ) [static, inherited]

Returns the Trithemian alphabet: abcdefghiklmnopqrstuxyzw.

Returns:
Trithemian alphabet.
String replaceAll ( String  toProcess) [inherited]

Replaces characters of the specified string by the replacements set in this.

Parameters:
toProcessString to process.
Returns:
String with replaced characters.
void setAlphabet ( char[]  alphabet) [inherited]

Sets the alphabet of this crypto component.

Parameters:
alphabetto set.
static Map<String,String> trithemianAlphabetReplacements ( ) [static, inherited]

Returns a map of default alphabet values and their replacements in the T. alphabet.

Returns:
Tritemian replacement map.

Field Details

char [] alphabet [protected, inherited]
boolean deleteWhitespace [protected, inherited]
int intKey [protected, inherited]
Logger logger = Logger.getLogger(this.getClass()) [protected, inherited]
Random random [package]
Map<String,String> replacementMap [protected, inherited]
Map<Character, List<String> > wordSubstitutions [protected, inherited]