From: Robert Klemme Date: 2004-08-19T21:00:53+09:00 Subject: Re: POT (partly offtopic) Re: Q: Shifting a hash anf and array "Meino Christian Cramer" schrieb im Newsbeitrag news:20040819.123945.92579085.Meino.Cramer@gmx.de... > > Sorry, Robert! This was only a nonsense joke. The only thing I > wanted to say was, that your non-rotating-but-offsetting-algorithm > will improve (therefore a kind of "incrementation of the Enigma > code") the code of the Enigma. Nothing more... Ah, ok. :-) > > Good luck! Some links that Google revealed: > > > > http://www.mirrors.wiretapped.net/security/cryptography/algorithms/enigma/ > > http://www.javaworld.com/jw-08-1998/jw-08-indepth-p3.html > > > > http://mathforum.org/library/topics/cryptography/ > > > > > > Kind regards > > > > robert > > > That's really funny, Robert! > What do you think, how often I hammered keywords like "Enigma", > "cryptography and such into Google the last days...but I never stumbled > across these... I searched for "enigma algorithms". I think they're all on the first page. > Each wheel has a notch (or two), which will turn "the next" wheel > one step at a certain point of rotation -- like the carry bit used > in assembly programming. I implemented this notch as a object > variable, which is set true at the position in question and has to > be evaluated by the "next wheel"-object. > > Like this? > > @carry=true # cause the first rotor is always rotated by one step if > # a new letter arrives to be encoded > > encoded = objarray.inject(letter) {|param, rotor| > rotor.rotate(@carry) > @carry=rotor.carry > rotor.encode param > } or encoded = objarray.inject( [letter, true] ) do |(param, carry), rotor| rotor.rotate carry [rotor.encode( param ), rotor.carry] end.shift Regards robert