Log in

View Full Version : [REQ] Enigma


MiTon
05-01-11, 11:54 AM
I just found this online enigma (http://www.subsim.com/radioroom/Hi%20TDW,%20%20I%20just%20found%20this%20online%20 enigma%20and%20was%20thinking%20that%20this%20woul d%20be%20cool%20ingame) !

Just an idea, but it would be pretty cool to have one of this ingame, when recieving crypted messages from BDU!??

There are also some origingal radio messages on this page!


regards


MiTon


EDIT:
Found this:

Python-Enigma (https://github.com/robhudson/python-paper-enigma/blob/master/enigma.py)

Paper Enigma (http://mckoss.com/Crypto/Enigma.htm)

stoianm
05-01-11, 11:56 AM
Cool ideea... if we will receive the BDU messages coded and we will uncode with this machine ... will be very realistic... maybe TDW will like the ideea:)

gap
05-01-11, 12:06 PM
I just found this online enigma (http://www.subsim.com/radioroom/Hi%20TDW,%20%20I%20just%20found%20this%20online%20 enigma%20and%20was%20thinking%20that%20this%20woul d%20be%20cool%20ingame) !

Just an idea, but it would be pretty cool to have one of this ingame, when recieving crypted messages from BDU!??

There are also some origingal radio messages on this page!


regards


MiTon

Very nice idea!
it would be cool having it implemented in game, together with Kriegsmarine grid system. It would add immersion.

Though, for appreciating much more these features, we should also enhance the radio msg system, by making communications between subs and BDU, more dynamic/varied and critical for patrol progress.

Is someone working on it? Maybe Zedi?

MiTon
05-01-11, 12:34 PM
I will do some tests with the python-enigma, but I've got no clue how the radiomessages system in SH5 works!

Maybe someone else knows?

reaper7
05-01-11, 12:51 PM
Found this script may be useful.
http://www.math.utoledo.edu/~codentha/Cryptanalysis/python/enigma/enigma.01.py


""" enigma.py
"""

import operator
from string import ascii_uppercase as UPPER
from copy import deepcopy
from permutations import Permutation,cycleform,permform

def char2int(key):
try:
c = key.upper()
return UPPER.index(c)
except:
return key

class Rotor(Permutation):

def __init__(self,perm,ringsetting='A',key='A',notches =()):

Permutation.__init__(self,perm)
self.notches = notches
self.setRing(ringsetting)
self.setKey(key)

def setRing(self,A):
r = char2int(A)
cycles = [[(x+r) % 26 for x in cycle] for cycle in self.C]
perm = permform(cycles)
self.P = perm
self.C = cycleform(perm)

def setKey(self,A):
k = char2int(A)
cycles = [[(x-k) % 26 for x in cycle] for cycle in self.C]
perm = permform(cycles)
self.P = perm
self.C = cycleform(perm)
self.key = UPPER[k]

def step(self):
cycles = [[(x-1) % 26 for x in cycle] for cycle in self.C]
perm = permform(cycles)
self.P = perm
self.C = cycleform(perm)

k = char2int(self.key)
k = (k+1) % 26
self.key = UPPER[k]

def trigger(self):
return self.key in self.notches

def rotor(strng):
return Permutation(tuple(strng.lower()))

# The rotors
I = Rotor("EKMFLGDQVZNTOWYHXUSPAIBRCJ",notches=("Q"))
II = Rotor("AJDKSIRUXBLHWTMCQGZNPYFVOE",notches=("E"))
III = Rotor("BDFHJLCPRTXVZNYEIWGAKMUSQO",notches=("V"))
IV = Rotor("ESOVPZJAYQUIRHXLNFTGKDCMWB",notches=("J"))
V = Rotor("VZBRGITYUPSDNHLXAWMJQO****",notches=("Z"))
VI = Rotor("JPGVOUMFYQBENHZRDKASXLICTW",notches=("Z","M"))
VII = Rotor("NZJHGRCXMYSWBOUFAIVLPEKQDT",notches=("Z","M"))
VIII = Rotor("FKQHTLXOCBJSPDZRAMEWNIUYGV",notches=("Z","M"))

# Used only in Model M-4 with thinB and thinC reflectors
beta = Rotor("LEYJVCNIXWPBQMDRTAKZGFUHOS")
gamma = Rotor("FSOKANUERHMBTIYCWLQPZXVGJD")

# The reflectors
B = Rotor("YRUHQSLDPXNGOKMIEBFZCWVJAT")
C = Rotor("FVPJIAOYEDRZXWGCTKUQSBNMHL")
# The reflectors used in Model M-4 with beta and gamma rotors.
thinB = Rotor("ENKQAUYWJICOPBLMDXZVFTHRGS")
thinC = Rotor("RDOBJNTKVEHMLFCWZAXGYIPSUQ")

# The cyclic permutation and its inverse
rho = Permutation("BCDEFGHIJKLMNOPQRSTUVWXYZA")

identity = Permutation("ABCDEFGHIJKLMNOPQRSTUVWXYZ")

# The 'QWERTZU' in military and civilian types. We
# have the 'QWERTZU' act on the left so we use the
# inverse of the input permutation.
military = Permutation("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
civilian = Permutation("QWERTZUIOASDFGHJKPYXCVBNML")

# This class still needs to be checked to see if it
# performs correctly.
class Enigma(object):

def __init__(self,
rotorList = (I,II,III),
reflector = B,
ringSettings = (),
stecker = identity,
qwertzu = military):
""" The rotor (wheel) list should be given from slowest to fastest:
U, W_L, W_M, W_R. The ring settings default to 'AA...', the
stecker and 'qwertzu' both default to the identity. The key
settings are made after the machine is initialized.
"""
self.qwertzu = qwertzu
self.rotors = [deepcopy(R) for R in rotorList]
self.rotors.insert(0,deepcopy(reflector))
self.nR = len(self.rotors)

self.__setRings(ringSettings)
self.setStecker(stecker)

def __repr__(self):
return repr(self.permutation)

def __str__(self):
return str(self.permutation)

def __call__(self,text):
return "".join(map(self.encipher,text))

def setStecker(self,stecker):
try:
self.SQ = stecker * self.qwertzu
except:
self.SQ = Permutation(stecker) * self.qwertzu

self.setPermutation()

def __setRings(self,ringSettings):
# Convert ring setting letters to numbers.
ringSettings = map(char2int,ringSettings)

# All ring settings default to 'A'.
nS = len(ringSettings)
ringSettings = (0,)*(self.nR - nS) + tuple(ringSettings)
for k,R in enumerate(self.rotors):
R.setRing(ringSettings[k])

def setKeys(self,keySettings):
# Convert key setting letters to numbers.
keySettings = map(char2int,keySettings)

# All key settings default to 'A'.
nK = len(keySettings)
keySettings = (0,)*(self.nR - nK) + tuple(keySettings)
for k,R in enumerate(self.rotors):
R.setKey(keySettings[k])

self.setPermutation()

def setPermutation(self):
self.permutation = (self.SQ >> reduce(operator.lshift,self.rotors))

def step(self):
if self.rotors[-2].trigger():
motion = (1,1,1)
elif self.rotors[-1].trigger():
motion = (0,1,1)
else:
motion = (0,0,1)

for i in range(3):
if motion[i]:
self.rotors[i-3].step()

self.setPermutation()

def encipher(self,c):
self.step()
return self.permutation.encipher(c)

MiTon
05-01-11, 12:54 PM
Found this script may be useful.
http://www.math.utoledo.edu/~codentha/Cryptanalysis/python/enigma/enigma.01.py (http://www.math.utoledo.edu/%7Ecodentha/Cryptanalysis/python/enigma/enigma.01.py)

...



Thx!

Will look at it!


EDIT:

great link!! thx

StarTrekMike
05-01-11, 05:57 PM
The use of a enigma machine to decode messages sounds pretty amazing to me.

it would also give us something to do in transit.


Mike

TheDarkWraith
05-01-11, 06:03 PM
My radio messages feature is already setup to have enigma messages :up:

stoianm
05-01-11, 11:39 PM
My radio messages feature is already setup to have enigma messages :up:
Can you make that the messages from BDU like ''convoy spoted'' that are displayed in messages box to be coded in the code that Miton will use if he will succed to put this machine in game?

Stormfly
05-02-11, 12:18 PM
we also need a codebook then, ithink it included the current used key for each day...? so you only need to code a "encoder enigma", which generate the encrypted message using the present key for each day... :O:

using a enigma feature for that special "commanders or (captains) messages" would be realistic, as the commander had to decode the message finaly by himself...

Sepp von Ch.
05-02-11, 12:27 PM
My radio messages feature is already setup to have enigma messages :up:

Would be PLEASE PLEASE PLEASE TDW possible to make a separate little mod with your radio messages? Please! http://i886.photobucket.com/albums/ac68/Hans_Witteman/Kaleun_Salivating.gif

Magic1111
05-02-11, 12:41 PM
using a enigma feature for that special "commanders or (captains) messages" would be realistic, as the commander had to decode the message finaly by himself...

"Nun mal los, 2WO! Offiziersfunkspruch. Wieder irgendso eine Sonderveranstaltung. Aber nicht mit uns! Unser Schlitten ist werftreif. Na, wird's bald?" - "Kommandantenspruch. Dreifach verschlüsselt. War ja noch nie da." -DAS BOOT- :|\\

"Let's go, 2WO! officer radio-message. A special event. But not with us! Our sled is ready to throw. Well,'s soon?" - ". commander saying triple encrypted never was there.."

stoianm
05-02-11, 12:45 PM
Will be to complicate to make multiple encription or multiple codes i think... so if he will succeed to make to work with the same code i will be happy enough:)

Stormfly
05-02-11, 01:04 PM
Will be to complicate to make multiple encription or multiple codes i think... so if he will succeed to make to work with the same code i will be happy enough:)

...but a little additional gameplay element, finding the right key for the present day in the code book.

MiTon
05-02-11, 01:49 PM
we also need a codebook then, ithink it included the current used key for each day...? so you only need to code a "encoder enigma", which generate the encrypted message using the present key for each day... :O:


And what would you do with the encoded message? Decode? :03: So if you don't wanna use an external app everytime you get a message, you'll need a decoder. If you put in the text manually or let it decode by a buttonpress doesn't matter to much.



using a enigma feature for that special "commanders or (captains) messages" would be realistic, as the commander had to decode the message finaly by himself...As from my understanding the captains messages were coded with two different codes. First one part to tell that this is a captains message, and the message itself.
As I could read on this german u-boat site (http://www.u-boot-zentrale.de/Enigma/enigma_j_standalone.html), there were at least three different codebooks.


Kenngruppenheft (http://www.u-boot-zentrale.de/Enigma/bilder/Enigma_kenn.htm) - "the normal codebook" with the codes one month (most times). Codes were efective for 24h, changed to 8h later (from here (http://www-ivs.cs.uni-magdeburg.de/bs/lehre/wise0102/progb/vortraege/steffensauer/enigma_bedienung.html)).
Kurzsignalheft (http://www.u-boot-zentrale.de/Enigma/bilder/Enigma_kurz.htm) - short message book, was used to shorten radiomessages and the transmissiontime to avoiding detection by the Huff-Duff Method
Wetterkurzschlüssel (http://www.u-boot-zentrale.de/Enigma/bilder/Wetterkurz.htm) - special codebook to shorten weatherreports (used when u-boat sends a weather report)


All were written with non waterproof ink, to be easy to destroy in case of emergency (capture or something like this)!
Also pretty bad when you have massive flooding:DL


So if build from scratch we should see in which way we can categorize the messages. Rest should be peanuts (hopefully :D)
Codebooks would be a very cool feature, but not nessecarily required, as it should be possible to hide required codes "inside" the message. Right code could be dialed automaticly.
But I'd prefer codebooks!


From the first quick looks at the code of the python-enigma (https://github.com/robhudson/python-paper-enigma/blob/master/enigma.py)I posted above is only simply a encoder, but this one looks like it be easy to integrate.


Found this script may be useful.
http://www.math.utoledo.edu/~codentha/Cryptanalysis/python/enigma/enigma.01.py (http://www.math.utoledo.edu/%7Ecodentha/Cryptanalysis/python/enigma/enigma.01.py)


Very good one indeed! Thx again reaper7!

Looks like a complete enigma implementation, but it uses core API functions, no longer existing in python, and is way more complex.

I don't have toons of time right now, but I'll try my best and dig in there!
First lesson for today and tomorrow: "How the enigma realy works!"


If anyone finds an other free implementation (maybe C#) or other usefull infos and stuff like codebooks ...:up:


regards

MiTon

MiTon
05-02-11, 01:51 PM
Will be to complicate to make multiple encription or multiple codes i think... so if he will succeed to make to work with the same code i will be happy enough:)


I don't think so, if we got one "softwarebuild" enigma! Just a matter of rotor plugs, ... Maybe hard to understand how to use them :)


...but a little additional gameplay element, finding the right key for the present day in the code book.

Yes, something to do during a boring nightwatch :)

Egan
05-02-11, 02:20 PM
Years ago when we started iBlitz (the forerunner of Wolves at War,) and we were still playing SH2 we got our hands on a downloadable Enigma machine and I spent a couple of weeks writing a codebook for it. I'll tell you, it sounds cool enough but it quickly gets to a point when you're trying to use it for patrol reports or decoding orders when you simply can't take it anymore if you have even a little bit of a life - not that too many people around here are likely to find that much of a problem...:D (**JOKE**).

It does add a phenomenal amount of realism but it's not for everybody.

I no longer have a copy of the codebook, unfortunately, else I'd stick it up on a download site for people to grab. I don't even know if there are any people around here who were involved in it. Iblitz, CB.., can't remember who else. But, hey, you never know.

MiTon
05-02-11, 02:51 PM
...

It does add a phenomenal amount of realism but it's not for everybody.
...


That's for sure, there has to be a option to make the "radiooperator" decrypt the messages! So if you get bored, let the crew do the job.


I no longer have a copy of the codebook, unfortunately, else I'd stick it up on a download site for people to grab. I don't even know if there are any people around here who were involved in it. Iblitz, CB.., can't remember who else. But, hey, you never know.
If not the original codebooks are used, one could simply use a password generator (http://www.techzoom.net/tools/password-generator.en) to build the "base"codebook!
But if someone finds yours .. great!



Guys plz don't get too excited, I don't know how much time I can spend on this project right now. Just thinking out loud and investigating!
But every guess, idea and help is appreciated!


regards

MiTon

urfisch
05-02-11, 02:55 PM
yes, an enigma applet ingame would be fantastic. decrypt the messages manually...great idea!!!

stoianm
05-02-11, 02:55 PM
Guys plz don't get too excited, I don't know how much time I can spend on this project right now. Just thinking out loud and investigating!
But every guess, idea and help is appreciated!


regards

MiTon
http://i886.photobucket.com/albums/ac68/Hans_Witteman/Kaleun_Goofy.gifhttp://i886.photobucket.com/albums/ac68/Hans_Witteman/Kaleun_Crying.gif

MiTon
05-02-11, 03:33 PM
http://i886.photobucket.com/albums/ac68/Hans_Witteman/Kaleun_Goofy.gifhttp://i886.photobucket.com/albums/ac68/Hans_Witteman/Kaleun_Crying.gif



:har:

Egan
05-02-11, 04:24 PM
[COLOR=White]
If not the original codebooks are used, one could simply use a password generator (http://www.techzoom.net/tools/password-generator.en) to build the "base"codebook!
But if someone finds yours .. great!
MiTon

If you can find it go for it. I've no idea where you'd even begin to look after all this time.

Stormfly
05-02-11, 05:16 PM
...my idea was only very important "commanders" messages should be encoded, and decoded manualy... (normal messages are displayed non coded because the radioman decoded them allready).

maybe there`s also a possibiliy to link that with important campaign and historycal events, maybe there is also a 25% chance to get exact enemy ship / group intel if in the area from time to time...

MiTon
05-02-11, 05:44 PM
...my idea was only very important "commanders" messages should be encoded, and decoded manualy... (normal messages are displayed non coded because the radioman decoded them allready).


At least optinal would be a musthave!
If the Enigma should be implemented, it's no big deal to set values for the personal taste (if you want to decode every message by yourself, decode every message automaticly, ...)



maybe there`s also a possibiliy to link that with important campaign and historycal events, maybe there is also a 25% chance to get exact enemy ship / group intel if in the area from time to time...I currently don't have a clue how the messagesystem in SH5 works so I can't tell.
Good startingpoint would be to grab the messages from the stockgame, reporting convoys, since they report convoys that realy exist ingame!

Stormfly
05-02-11, 06:01 PM
Good startingpoint would be to grab the messages from the stockgame, reporting convoys, since they report convoys that realy exist ingame!

yap, thats what i thought... generate encoded messages from that rare but detailed radio contacts...

...mix that with historical important events (have to be in sync with existing historical campaign events),

...maybe also BDU movement and resupply coordinates (coordinates have to be hidden on map until correct decoded) :hmmm:

MiTon
05-04-11, 02:49 PM
While gathering more infos, I found this site (http://www.w1tp.com/enigma/) containing a link to a codebook generator (http://www.w1tp.com/enigma/codebooktool.zip) so the codebooks will be the smallest problem!

regards

urfisch
05-04-11, 02:51 PM
the_dark_wraith might know, how to add an ingame-applet for the enigma. he managed to create some dlls, which allow to execute any code ingame. maybe you should write a pm.

:up: