SUBSIM Radio Room Forums



SUBSIM: The Web's #1 resource for all submarine & naval simulations since 1997

Go Back   SUBSIM Radio Room Forums > Silent Hunter 3 - 4 - 5 > SH5 Mods Workshop
Forget password? Reset here

Reply
 
Thread Tools Display Modes
Old 05-01-11, 11:54 AM   #1
MiTon
Sparky
 
Join Date: Apr 2010
Location: Germany
Posts: 157
Downloads: 270
Uploads: 2
Default [REQ] Enigma

I just found this online enigma !

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

Paper Enigma

Last edited by MiTon; 05-01-11 at 12:04 PM.
MiTon is offline   Reply With Quote
Old 05-01-11, 11:56 AM   #2
stoianm
Ocean Warrior
 
Join Date: Dec 2010
Location: Montreal, Canada
Posts: 2,776
Downloads: 833
Uploads: 11
Default

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
stoianm is offline   Reply With Quote
Old 05-01-11, 12:06 PM   #3
gap
Navy Seal
 
Join Date: Jan 2011
Location: CJ8937
Posts: 8,215
Downloads: 793
Uploads: 10
Default

Quote:
Originally Posted by MiTon View Post
I just found this online enigma !

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?
gap is offline   Reply With Quote
Old 05-01-11, 12:34 PM   #4
MiTon
Sparky
 
Join Date: Apr 2010
Location: Germany
Posts: 157
Downloads: 270
Uploads: 2
Default

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?
MiTon is offline   Reply With Quote
Old 05-01-11, 12:51 PM   #5
reaper7
sim2reality
 
Join Date: Jun 2007
Location: AM 82
Posts: 2,280
Downloads: 258
Uploads: 30
Default

Found this script may be useful.
http://www.math.utoledo.edu/~codenth...a/enigma.01.py

PHP Code:
""" 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:
        
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):
        
char2int(A)
        
cycles = [[(x+r) % 26 for x in cycle] for cycle in self.C]
        
perm permform(cycles)
        
self.perm
        self
.cycleform(perm)

    
def setKey(self,A):
        
char2int(A)
        
cycles = [[(x-k) % 26 for x in cycle] for cycle in self.C]
        
perm permform(cycles)
        
self.perm
        self
.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.perm
        self
.cycleform(perm)

        
char2int(self.key)
        
= (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
reaper7 is offline   Reply With Quote
Old 05-01-11, 12:54 PM   #6
MiTon
Sparky
 
Join Date: Apr 2010
Location: Germany
Posts: 157
Downloads: 270
Uploads: 2
Default

Quote:
Originally Posted by reaper7 View Post

Thx!

Will look at it!


EDIT:

great link!! thx

Last edited by MiTon; 05-01-11 at 01:52 PM.
MiTon is offline   Reply With Quote
Old 05-01-11, 05:57 PM   #7
StarTrekMike
Navy Dude
 
Join Date: Jan 2006
Location: Made in Vermont
Posts: 178
Downloads: 137
Uploads: 0
Default

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
__________________
I think we lost em...hey whats that pinging sound?
StarTrekMike is offline   Reply With Quote
Old 05-01-11, 06:03 PM   #8
TheDarkWraith
Black Magic
 
Join Date: Jun 2007
Posts: 11,962
Downloads: 147
Uploads: 5


Default

My radio messages feature is already setup to have enigma messages
TheDarkWraith is offline   Reply With Quote
Old 05-01-11, 11:39 PM   #9
stoianm
Ocean Warrior
 
Join Date: Dec 2010
Location: Montreal, Canada
Posts: 2,776
Downloads: 833
Uploads: 11
Default

Quote:
Originally Posted by TheDarkWraith View Post
My radio messages feature is already setup to have enigma messages
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?
stoianm is offline   Reply With Quote
Old 05-02-11, 12:18 PM   #10
Stormfly
Serial Port Protector
 
Stormfly's Avatar
 
Join Date: Sep 2002
Posts: 1,424
Downloads: 370
Uploads: 0
Default

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...

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...
__________________
Stormy......

Stormfly is offline   Reply With Quote
Old 05-02-11, 12:27 PM   #11
Sepp von Ch.
Sea Lord
 
Join Date: Dec 2009
Location: In my U-552 and Tiger
Posts: 1,732
Downloads: 788
Uploads: 0
Default

Quote:
Originally Posted by TheDarkWraith View Post
My radio messages feature is already setup to have enigma messages
Would be PLEASE PLEASE PLEASE TDW possible to make a separate little mod with your radio messages? Please!
__________________
U-552
Tiger
IDF
Sepp von Ch. is offline   Reply With Quote
Old 05-02-11, 12:41 PM   #12
Magic1111
Silent Hunter
 
Join Date: Sep 2008
Location: Germany - Sailing on U-552 in North Atlantic
Posts: 4,429
Downloads: 783
Uploads: 0


Default

Quote:
Originally Posted by Stormfly View Post
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.."
__________________
Magic1111 is offline   Reply With Quote
Old 05-02-11, 12:45 PM   #13
stoianm
Ocean Warrior
 
Join Date: Dec 2010
Location: Montreal, Canada
Posts: 2,776
Downloads: 833
Uploads: 11
Default

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
stoianm is offline   Reply With Quote
Old 05-02-11, 01:04 PM   #14
Stormfly
Serial Port Protector
 
Stormfly's Avatar
 
Join Date: Sep 2002
Posts: 1,424
Downloads: 370
Uploads: 0
Default

Quote:
Originally Posted by stoianm View Post
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.
__________________
Stormy......

Stormfly is offline   Reply With Quote
Old 05-02-11, 01:49 PM   #15
MiTon
Sparky
 
Join Date: Apr 2010
Location: Germany
Posts: 157
Downloads: 270
Uploads: 2
Default

Quote:
Originally Posted by Stormfly View Post
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...
And what would you do with the encoded message? Decode? 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.

Quote:

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, there were at least three different codebooks.
  • Kenngruppenheft - "the normal codebook" with the codes one month (most times). Codes were efective for 24h, changed to 8h later (from here).
  • Kurzsignalheft - short message book, was used to shorten radiomessages and the transmissiontime to avoiding detection by the Huff-Duff Method
  • Wetterkurzschlüssel - 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


So if build from scratch we should see in which way we can categorize the messages. Rest should be peanuts (hopefully )
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 I posted above is only simply a encoder, but this one looks like it be easy to integrate.


Quote:
Originally Posted by reaper7 View Post
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 ...


regards

MiTon






MiTon is offline   Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 02:50 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright © 1995- 2025 Subsim®
"Subsim" is a registered trademark, all rights reserved.