Wikunia / Enigma.jl

Enigma decode/encode and cracking
https://opensourc.es/blog/enigma-and-bombe
MIT License
17 stars 1 forks source link

Could the result output be changed? #22

Closed ghost closed 3 years ago

ghost commented 3 years ago

Currently when your program finds a result it displays:

1-element Array{EnigmaMachine,1}:
 EnigmaMachine([2, 1, 4, 3, 6, 5, 8, 7, 10, 9  …  18, 17, 20, 19, 21, 22, 23, 24, 25, 26], (Enigma.Rotor("III", 1, [2, 4, 6, 8, 10, 12, 3, 16, 18, 20  …  9, 23, 7, 1, 11, 13, 21, 19, 17, 15], [20, 1, 7, 2, 16, 3, 19, 4, 17, 5  …  25, 9, 24, 10, 23, 12, 18, 11, 15, 13], 24, 23), Enigma.Rotor("II", 2, [1, 10, 4, 11, 19, 9, 18, 21, 24, 2  …  17, 7, 26, 14, 16, 25, 6, 22, 15, 5], [1, 10, 16, 3, 26, 23, 18, 12, 6, 2  …  17, 7, 5, 14, 8, 24, 13, 9, 22, 19], 24, 6), Enigma.Rotor("I", 3, [5, 11, 13, 6, 12, 7, 4, 17, 22, 26  …  24, 21, 19, 16, 1, 9, 2, 18, 3, 10], [21, 23, 25, 7, 1, 4, 6, 16, 22, 26  …  8, 24, 19, 12, 18, 9, 14, 17, 15, 10], 24, 18)), Enigma.UKW("B", [25, 18, 21, 8, 17, 19, 12, 4, 16, 24  …  5, 2, 6, 26, 3, 23, 22, 10, 1, 20]))

I don't understand what all this means. Would it be possible to give it in a friendlier way, such as that shown by Cryptool:

III, V, I / 25, 3, 7 / BL CK DG FP IR MO QW ST UZ VY / GBU

Wikunia commented 3 years ago

By default Julia displays the struct with all its fields. It's possible however to overwrite that method to specify the output.

I see that you're interested in this project and your post about it the previous issue looks great. Are you interested in doing pull requests as well?

For this particular case one needs to define s show method for example: https://stackoverflow.com/a/57885705/2501747

ghost commented 3 years ago

I don't really have any coding skills, apart from html, css and some very basic php. And I had never heard of Julia before I found this. So I can't contribute to the code unfortunately.

Happy to help with testing though. :-)

Wikunia commented 3 years ago

Do you mind testing it?

] add Enigma#feature-improved-output

Thanks in advance

ghost commented 3 years ago

That's wonderful!!

julia> enigmas = run_cracking(bombe; log=false)
1 Enigma machine(s):
- III, II, I | 24 24 1 | UKW: B | AB CD EF GH IJ KL MN OP QR ST

Exactly what is needed. Great work!

The only other suggestion would be to do the same in other places. Like here:

julia> set_rotors!(enigma, 4,2,1)
(Enigma.Rotor("IV", 1, [5, 19, 15, 22, 16, 26, 10, 1, 25, 17  …  14, 6, 20, 7, 11, 4, 3, 13, 23, 2], [8, 26, 23, 22, 1, 18, 20, 14, 12, 7  …  10, 13, 2, 19, 11, 4, 25, 15, 9, 6], 1, 11), Enigma.Rotor("II", 2, [1, 10, 4, 11, 19, 9, 18, 21, 24, 2  …  17, 7, 26, 14, 16, 25, 6, 22, 15, 5], [1, 10, 16, 3, 26, 23, 18, 12, 6, 2  …  17, 7, 5, 14, 8, 24, 13, 9, 22, 19], 1, 6), Enigma.Rotor("I", 3, [5, 11, 13, 6, 12, 7, 4, 17, 22, 26  …  24, 21, 19, 16, 1, 9, 2, 18, 3, 10], [21, 23, 25, 7, 1, 4, 6, 16, 22, 26  …  8, 24, 19, 12, 18, 9, 14, 17, 15, 10], 1, 18))

But the one you have done is by far the most important. Thank you.

Wikunia commented 3 years ago

This should be fixed now. Sorry for the long delay of publishing the new version.