Ancient cryptography my hobby thanks to the book of David Kahn, I applied year cipher in Ruby classes trying to handle this As for being one of them and for them, a useful thing is that in Ruby I have the following implementation and welcome any improvement. Ruby / Python / Pearl or pseudo code is right for me Thanks for any thoughts. key # condensed
is a method that removes duplicated characters from a given word.
square sketches < Key attr_reader: full_key attr_reader: Alpha ,: def start ralpha (key) super (key) @alpha = Hash.new @ralpha = Hash.new @full_key = checkboard () gen_rings () end # === Checkboard # # # Shuffle code number # to avoid # gradual allocation alphabet little # # regular rectangle # ----------------- # ARBESQU (LAN = 7) (height = 4) # command let ARBESQUCDFGHIJKLMNOPTVWXYZ / - # first pass # # A Arbiiskeseedifjiacaijekeelmanpitiviaksaj / - C = 0 0 x 6 AC Arbiskwadfijiacaiackeelmanpitiviaksaj / - C = 6 1 x 6 ACK Arbiskwad FijiIlmMnOPTVV / XC - 12 = 2x6 # ACKV will be generated. RBESQUDFGHIJLMNOPTWXYZ / --c = 183 x 6 # ACKVR BESQUDFGHIJLMNOPTWXYZ / - c = 0 x 5 # ACKVRD BESQUFGHIJLMNOPTWXYZ / --C = 5 1 x5 # ... # ACKVRDLWBFMXEGNYSHOZQIP / UJT- # # Random Rectangle # ----- -------------- # key subway condensed information Subway (len = 6) (height = 5) # S UBWAYCDEFGHIJKLMNOPQRTVXZ / - c = 0 0 x 5 # SC UBWAYDEFGHIJKLMNOPQRTVXZ / - C = 5 1 x 5 SCI UBWAYDEFGHJKLMNOPQRTVXZ / - c = 10 2 x 5 # SCIO UBWAYDEFGHJKLMNPQRTVXZ / --C = 153 x5 # SCIOX UBWAYDEFGHJKLMNPQRTVZ / - c = 20 4 x5 # SCIOXU BWAYDEFGHJKLMNPQRTVZ / --C = 0 x4 #. .. # SCIOXUDJPZBEKQ / WFLR- AG YHMNTV c = 1 1 x 1 # SCIOXUDJPZBEKQ / WFLR- AGM YHNTV c = 2 2 x 1 # SCIOXUDJPZBEKQ / WFLR-AGMT YHNV c = 3 3 x 1 # SCIOXUDJPZBEKQ / WFLR-AGMTYHNV # Def checkboard Word = (@key + Base) .condensed.dup lane = @ key.condensed.length height = BASE.length / lane # strange rectangle # if (BASE.length% lane)! = 0 height = height + 1 end print "\ nThe size of the checkboard is # {len} x # {height} \ n" res = "" (lane -1). Do Downto (0). I | Make upto (height - 1). J. If word.length & lt; = (Height - 1) Then return + word else c = word.slice! (I * j) if not c.nil? Then res = res + c.chr end end end end return reserve end # == gen_rings # # specify a code number for each letter. Each code number is serially allocated from # two locks, with a 0..7 and # other 80..99 ## # Allocation is done on the following criteria - If the letter is one of the ESANTIRU, then specify a single code number - and specify the two two letters # # Generate both encoding and decoding rings # # XXX FIXME 80- 99 is hard to use #df gen_rings ind_u = 0 ind_d = 80 words = @ full_key.dup word.scan (/./) do | C | If c = ~ / [ESANTIRU] / @alpha [C] = ind_u @ralpha [ind_u] = c ind_u = ind_u + rest 1 @alpha [C] = ind_d @ralpha [ind_d] = c ind_d = ind_d +1 end end End # - Gene_Rier's
Maybe you should try instead? There are many helpful people there.
Comments
Post a Comment