Finally removed the "bug" with the bad encryption; It was a known anomaly in the historical enigma machine that I oversaw. So I added this "historical bug" as a feature to the enigma. Thanks to the author of the java script version of the enigma machine for the hint :)

This commit is contained in:
vanitasvitae 2015-02-17 01:07:33 +01:00
parent 8fecb6f7b7
commit 2e891d8213
8 changed files with 22 additions and 12 deletions

View file

@ -2,6 +2,8 @@
<dictionary name="vanitas">
<words>
<w>plugboard</w>
<w>ringsetting</w>
<w>ringsettings</w>
</words>
</dictionary>
</component>

View file

@ -8,8 +8,8 @@ android {
applicationId "de.vanitasvitae.enigmandroid"
minSdkVersion 15
targetSdkVersion 20
versionCode 1
versionName "1.0"
versionCode 5
versionName "17.02.2015-beta"
}
buildTypes {
release {

Binary file not shown.

View file

@ -1,8 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="de.vanitasvitae.enigmandroid"
android:versionCode="00004"
android:versionName="11.02.2015-beta">
package="de.vanitasvitae.enigmandroid">
<application
android:allowBackup="true"

View file

@ -16,6 +16,7 @@ public class Enigma
private Rotor r3;
//Slot for the reflector
private Rotor reflector;
private boolean anomaly;
//Standard configuration (rotors 1-3, reflector B, all three rotors set to position 1)
private static final int[] STANDARD_CONFIGURATION = {1,2,3,2,1,1,1};
@ -56,7 +57,7 @@ public class Enigma
/**
* Perform crypto on char.
* Beforehand rotate rotors..
* Beforehand rotate rotors. Also implement the rotor anomaly.
* @param k input char
* @return output char
*/
@ -64,9 +65,14 @@ public class Enigma
{
//Rotate rotors
r1.incrementCounter();
if(r1.isAtTurnoverPosition()) {
if(r1.isAtTurnoverPosition() || this.anomaly)
{
r2.incrementCounter();
if (r2.isAtTurnoverPosition()) {
//Handle Anomaly
this.anomaly = false;
if(r2.getCounter() == r2.getTurnOver()-1) this.anomaly=true;
if (r2.isAtTurnoverPosition())
{
r3.incrementCounter();
}
}

View file

@ -1,7 +1,7 @@
package de.vanitasvitae.enigmandroid;
/**
* Klasse, die eine Walze der Enigmamaschine representiert (I-V,A-C)
* Class representing a rotor of the Enigma machine (I-V,A-C)
* @author vanitas
*
*/
@ -39,8 +39,7 @@ public class Rotor
//Atributes of the rotor
private Integer[] rotor; //choose one of rotor1-5
private Integer[] rrotor; //choose one of backwardsRotor1-5
private int ringsetting; //http://people.physik.hu-berlin.de/~palloks/js/enigma/enigma-u_v20.html
//My fault?
private int ringsetting;
private int turnOver;
private int counter;
private String name;
@ -182,6 +181,11 @@ public class Rotor
return this.getCounter() == this.turnOver;
}
public int getTurnOver()
{
return this.turnOver;
}
/**
* Return the name of the rotor
* @return name

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="version" translatable="false">0.1-11.02.2015</string>
<string name="version" translatable="false">0.1-17.02.2015</string>
<string name="app_name">EnigmAndroid</string>
<string name="action_version">Version</string>
<string name="action_reset">Reset</string>

Binary file not shown.