VignereCipherAnalyzer Class Reference

Inheritance diagram for VignereCipherAnalyzer:
Collaboration diagram for VignereCipherAnalyzer:

List of all members.


Detailed Description

Class to analyse ciphers based on the Vignère substitution

Author:
jhermes

Public Types

enum  DecipherMethod {
  PLAYFAIR = ("de.uni_koeln.spinfo.cryptology.cryptanalysis.plaintextgenerators.PlayfairCipherAnalyzer"), POLYBUS = ("de.uni_koeln.spinfo.cryptology.cryptanalysis.plaintextgenerators.PolybusCipherAnalyzer"), CAESAR = ("de.uni_koeln.spinfo.cryptology.cryptanalysis.plaintextgenerators.CaesarCipherAnalyzer"), VIGNERE = ("de.uni_koeln.spinfo.cryptology.cryptanalysis.plaintextgenerators.VignereCipherAnalyzer"),
  ATBASH = ("de.uni_koeln.spinfo.cryptology.cryptanalysis.plaintextgenerators.AtbashCipherAnalyzer"), STEGANOGRAPHIA_I = ("SteganographiaICipherAnalyzer"), STEGANOGRAPHIA_INCANTATION = ("de.uni_koeln.spinfo.cryptology.steganalysis.plaintextgenerators.SteganographiaIncantationAnalyzer"), POLYGRAPHIA_I = ("de.uni_koeln.spinfo.cryptology.steganalysis.plaintextgenerators.PolygraphiaICipherAnalyzer"),
  POLYGRAPHIA_IV = ("de.uni_koeln.spinfo.cryptology.steganalysis.plaintextgenerators.PolygraphiaIVCipherAnalyzer"), POLYGRAPHIA_V = ("de.uni_koeln.spinfo.cryptology.cryptanalysis.plaintextgenerators.PolygraphiaVCipherGenerator")
}
enum  ConfigurationElement {
  KEY = ("Key"), ALPHABET = ("Alphabet"), REPLACEMENTS = ("Replacements"), WORD_SUBSTITUTES = ("Substitutes"),
  DELETE_WHITESPACE = ("Whitespace deletion")
}

Public Methods

 VignereCipherAnalyzer ()
 VignereCipherAnalyzer (String key)
 VignereCipherAnalyzer (String key, char[] alphabet)
String decipher (String cipherText)
String decipher (List< String > words)
void configure (Map< ConfigurationElement, String > configurations)
char[][] buildPlayfairMatrix (String key)
String atbashCipher (String toSubstitute, Map< Character, Character > substitutions)
String atbashCipher (String toSubstitute, char[] alphabet)
String atbashCipher (String toSubstitute)
String caesarCipher (String toSubstitute, Map< Character, Character > substitutions)
String caesarCipher (String toSubstitute, int addition, char[] alphabet)
String caesarCipher (String toSubstitute, int addition)
String vignereCipher (String toSubstitute, List< Map< Character, Character >> vignereSubstitutions, int position)
String vignereCipher (String toSubstitute, String key, char[] alphabet, int position)
String vignereCipher (String toSubstitute, String key, int position)
String polygraphiaVCipher (String toSubstitute, List< Map< Character, Character >> vignereSubstitutions, int position)
String polygraphiaVCipher (String toSubstitute, char[] alphabet, int position)
String polygraphiaVCipher (String toSubstitute, int position)
String polybusCipher (String toSubstitute, Map< Integer, Integer > substitutions)
String polybusCipher (String toSubstitute, char[] alphabet, int matrixWidth)
String polybusCipher (String toSubstitute)
String playfairCipher (String toSubstitute, char[][] matrix, Map< Character, Point > charPositions)
String playfairCipher (String toSubstitute, String key)
Map< Character, Character > getSubstitutions ()
void setSubstitutions (Map< Character, Character > substitutions)
List< Map< Character, Character > > getVignereSubstitutions ()
void setVignereSubstitutions (List< Map< Character, Character >> vignereSubstitutions)
Map< Integer, Integer > getPolybusSubstitutions ()
void setPolybusSubstitutions (Map< Integer, Integer > polybusSubstitutions)
char[][] getPlayfairMatrix ()
void setPlayfairMatrix (char[][] playfairMatrix)
Map< Character, Point > getPlayfairMatrixCharPositions ()
void setPlayfairMatrixCharPositions (Map< Character, Point > playfairMatrixCharPositions)
String getKey ()
void setKey (String key)
int getAddition ()
void setAddition (int addition)
boolean isDeleteWhitespaces ()
void setDeleteWhitespaces (boolean deleteWhitespaces)
int getPosition ()
void setPosition (int position)
void incPosition (int increment)
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 char[] getDefaultAlphabet ()
static char[] getDefaultAlphabetWithoutChar (char ch)
static char[] getTrithemianAlphabet ()
static Map< String, String > trithemianAlphabetReplacements ()

Protected Methods

Map< Character, Character > buildCeasarSubstitutionMap (char[] alphabet, int addition)
Map< Integer, Integer > buildPolybusSubstitutionMap (char[] alphabet, int matrixWidth)
List< Integer > getPolybusInputUnits (String input)
String getPolybusOutputUnit (Integer output)
Map< Character, Character > buildAtbashSubstitutionMap (char[] alphabet)
List< Map< Character, Character > > buildVignereSubstitutions (char[] alphabet, String key)
List< String > getBigrams (String toSplit)
Map< Character, Point > getCharPositions (char[][] matrix)
boolean checkStringKey (String stringKey, String defaultKey)
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

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

Member Enumeration Documentation

enum ConfigurationElement [inherited]

Enumeration of potential configuration elements for Cryptologers.

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

Enumeration of decipher methods.

Author:
jhermes
Enumerator:
PLAYFAIR 
POLYBUS 
CAESAR 
VIGNERE 
ATBASH 
STEGANOGRAPHIA_I 
STEGANOGRAPHIA_INCANTATION 
POLYGRAPHIA_I 
POLYGRAPHIA_IV 
POLYGRAPHIA_V 

Constructors

Generates a crypto-analyzer based that have to be configured via configure() method.

VignereCipherAnalyzer ( String  key)

Generates a crypto-analyzer based on the specified key and the latin default alphabet (a-z).

Parameters:
keyVignère key.
VignereCipherAnalyzer ( String  key,
char[]  alphabet 
)

Generates a crypto-analyzer based on the specified key and alphabet.

Parameters:
keyVignère key.
alphabetAlphabet of valid substitution characters.

Method Details

String atbashCipher ( String  toSubstitute,
Map< Character, Character >  substitutions 
) [inherited]

Substitutes the specified string using the Atbash method (monoalphabetical, monographical, monopartit).

Parameters:
toSubstituteString to substitute.
substitutionsMap of substitutions.
Returns:
Substitution String.
String atbashCipher ( String  toSubstitute,
char[]  alphabet 
) [inherited]

Substitutes the specified string using the Atbash method (monoalphabetical, monographical, monopartit).

Parameters:
toSubstituteString to substitute
alphabetDefined alphabet.
Returns:
Substitution String.
String atbashCipher ( String  toSubstitute) [inherited]

Substitutes the specified string using the Atbash method (monoalphabetical, monographical, monopartit). Uses latin default alphabet.

Parameters:
toSubstituteString to substitute
Returns:
Substitution String.
Map<Character,Character> buildAtbashSubstitutionMap ( char[]  alphabet) [protected, inherited]
Map<Character,Character> buildCeasarSubstitutionMap ( char[]  alphabet,
int  addition 
) [protected, virtual, inherited]

Implements CryptoCipherUtils.

char [][] buildPlayfairMatrix ( String  key) [virtual, inherited]

Implements CryptoCipherUtils.

Map<Integer,Integer> buildPolybusSubstitutionMap ( char[]  alphabet,
int  matrixWidth 
) [protected, virtual, inherited]

Implements CryptoCipherUtils.

List<Map<Character,Character> > buildVignereSubstitutions ( char[]  alphabet,
String  key 
) [protected, inherited]
String caesarCipher ( String  toSubstitute,
int  addition,
char[]  alphabet 
) [inherited]

Substitutes the specified string using the Caesar method (monoalphabetical, monographical, monopartit).

Parameters:
toSubstituteString to substitute.
additionKey to generate substitution matrix.
alphabetDefined alphabet.
Returns:
Substitution string.
String caesarCipher ( String  toSubstitute,
Map< Character, Character >  substitutions 
) [inherited]

Substitutes the specified string using the Caesar method (monoalphabetical, monographical, monopartit).

Parameters:
toSubstituteString to substitute.
substitutionsDefined Substitutions.
Returns:
Substitution string.
String caesarCipher ( String  toSubstitute,
int  addition 
) [inherited]

Substitutes the specified string using the Caesar method (monoalphabetical, monographical, monopartit). Uses latin default alphabet.

Parameters:
toSubstituteString to substitute.
additionKey to generate substitution matrix.
Returns:
Substitution string.
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 checkStringKey ( String  stringKey,
String  defaultKey 
) [protected, inherited]
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 Cryptologer with the specified ConfigurationElement - String value pairs.

Parameters:
configurationsMap of ConfigurationElement - String value pairs

Implements Cryptologer.

String decipher ( List< String >  words)

Returns the plain text of the specified cipher word sequence.

Parameters:
wordsSequence of words to decipher.
Returns:
plain text.

Implements Decipherer.

String decipher ( String  cipherText)

Deciphers the specified text.

Parameters:
cipherTexttext to decipher.
Returns:
deciphered text.

Implements Decipherer.

int getAddition ( ) [inherited]
Set<Character> getAlphabet ( ) [inherited]

Returns a set of the alphabet of replacement characters

Returns:
Set<Character> getAlphabet ( ) [inherited]

Returns the alphabet of this crypto component.

Returns:
alphabet of this crypto component.
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.
List<String> getBigrams ( String  toSplit) [protected, inherited]
Map<Character,Point> getCharPositions ( char  matrix[][]) [protected, inherited]
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.
String getKey ( ) [inherited]
char [][] getPlayfairMatrix ( ) [inherited]
Map<Character, Point> getPlayfairMatrixCharPositions ( ) [inherited]
List<Integer> getPolybusInputUnits ( String  input) [protected, virtual, inherited]

Implements CryptoCipherUtils.

String getPolybusOutputUnit ( Integer  output) [protected, virtual, inherited]

Implements CryptoCipherUtils.

Map<Integer, Integer> getPolybusSubstitutions ( ) [inherited]
int getPosition ( ) [inherited]
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]
Map<Character, Character> getSubstitutions ( ) [inherited]
static char [] getTrithemianAlphabet ( ) [static, inherited]

Returns the Trithemian alphabet: abcdefghiklmnopqrstuxyzw.

Returns:
Trithemian alphabet.
List<Map<Character, Character> > getVignereSubstitutions ( ) [inherited]
void incPosition ( int  increment) [inherited]
boolean isDeleteWhitespaces ( ) [inherited]
String playfairCipher ( String  toSubstitute,
char  matrix[][],
Map< Character, Point >  charPositions 
) [inherited]

Substitutes the specified string using the Playfair method (monoalphabetical, bigraphical, bipartit). The substitution string will be lower cased, 'j' will be treated as 'i'. If it contains letters not defined in the matrix (key letters + default alphabet letters), they were replaced by 'x' (this is also true for whitespace). be treated as 'i'. The matrix should contain a 'x', because this character is needed as default char.

Parameters:
toSubstituteString to substitute.
matrixSubstitution matrix.
charPositionsMap of matrix' character positions
Returns:
substitution string.
String playfairCipher ( String  toSubstitute,
String  key 
) [inherited]

Substitutes the specified string using the Playfair method (monoalphabetical, bigraphical, bipartit). The methods underlying matrix will be constructed by the specified key string. The substitution string will be lower cased, 'j' will be treated as 'i'. If it contains letters not defined in the matrix (key letters + default alphabet letters), they were replaced by 'x' (this is also true for whitespace). The characters of the key will be placed at the first positions of the matrix. Upper case letters were transformed to lower case letters. Here again, 'j' will be treated as 'i'. The key should not contain more than 24 different letters (25, if it contains a 'x', because this character is needed as default char).

Parameters:
toSubstituteString to substitute.
keythe key characters.
Returns:
substitution string.
String polybusCipher ( String  toSubstitute,
char[]  alphabet,
int  matrixWidth 
) [inherited]

Substitutes the specified string using the Polybus method (monoalphabetical, monographical, bipartit).

Parameters:
toSubstituteString to substitute
alphabetDefined alphabet.
matrixWidthWidth of the substitution matrix.
Returns:
Substitution String
String polybusCipher ( String  toSubstitute,
Map< Integer, Integer >  substitutions 
) [inherited]

Substitutes the specified string using the Polybus method (monoalphabetical, monographical, bipartit).

Parameters:
toSubstituteString to substitute.
substitutionsMap of substitutions
Returns:
Substitution string.
String polybusCipher ( String  toSubstitute) [inherited]

Substitutes the specified string using the Polybus method (monoalphabetical, monographical, bipartit). Uses latin default alphabet ('j'='i') and matrixWidth of 5.

Parameters:
toSubstituteString to substitute.
Returns:
Substitution string.
String polygraphiaVCipher ( String  toSubstitute,
List< Map< Character, Character >>  vignereSubstitutions,
int  position 
) [inherited]

Substitutes the specified string using the method from Trithemius' Polygraphia V (polyalphabetical, monographical, monopartit).

Parameters:
toSubstituteString to substitute.
vignereSubstitutionsList of substitution maps.
Returns:
Substitution string.
String polygraphiaVCipher ( String  toSubstitute,
int  position 
) [inherited]

Substitutes the specified string using the method from Trithemius' Polygraphia V (polyalphabetical, monographical, monopartit). Uses Trithemian alphabet (abcdefghiklmopqrstuxyzw).

Parameters:
toSubstituteString to substitute.
Returns:
Substitution string.
String polygraphiaVCipher ( String  toSubstitute,
char[]  alphabet,
int  position 
) [inherited]

Substitutes the specified string using the method from Trithemius' Polygraphia V (polyalphabetical, monographical, monopartit).

Parameters:
toSubstituteString to substitute.
alphabetDefined alphabet.
Returns:
Substitution string.
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 setAddition ( int  addition) [inherited]
void setAlphabet ( char[]  alphabet) [inherited]

Sets the alphabet of this crypto component.

Parameters:
alphabetto set.
void setDeleteWhitespaces ( boolean  deleteWhitespaces) [inherited]
void setKey ( String  key) [inherited]
void setPlayfairMatrix ( char  playfairMatrix[][]) [inherited]
void setPlayfairMatrixCharPositions ( Map< Character, Point >  playfairMatrixCharPositions) [inherited]
void setPolybusSubstitutions ( Map< Integer, Integer >  polybusSubstitutions) [inherited]
void setPosition ( int  position) [inherited]
void setSubstitutions ( Map< Character, Character >  substitutions) [inherited]
void setVignereSubstitutions ( List< Map< Character, Character >>  vignereSubstitutions) [inherited]
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.
String vignereCipher ( String  toSubstitute,
String  key,
char[]  alphabet,
int  position 
) [inherited]

Substitutes the specified string using the Vignère method (polyalphabetical, monographical, monopartit).

Parameters:
toSubstituteString to substitute.
keyKey to generate substitution matrix.
alphabetDefined alphabet.
Returns:
Substitution string.
String vignereCipher ( String  toSubstitute,
String  key,
int  position 
) [inherited]

Substitutes the specified string using the Vignère method (polyalphabetical, monographical, monopartit). Uses latin default alphabet.

Parameters:
toSubstituteString to substitute.
keyKey to generate substitution matrix.
Returns:
Substitution string.
String vignereCipher ( String  toSubstitute,
List< Map< Character, Character >>  vignereSubstitutions,
int  position 
) [inherited]

Substitutes the specified string using the Vignère method (polyalphabetical, monographical, monopartit).

Parameters:
toSubstituteString to substitute.
vignereSubstitutionsDefined Substitutions.
Returns:
Substitution string.

Field Details

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