Bifid cipher: Difference between revisions

Content deleted Content added
Lanky79 (talk | contribs)
Midaz (talk | contribs)
Added Uiua solution
Line 2,296: Line 2,296:
</pre>
</pre>


=={{header|Uiua}}==
===Standard===
The following just uses the standard version of the cipher.
<syntaxhighlight lang="uiua">
S ← "ABCDEFGHIKLMNOPQRSTUVWXYZ"
P ← ↯⊟.√⧻.S
Prep ← ▽∊:S.∧⍜⊡⋅@I⊚⌕@J.⌵
Bifid ← setinv(
⊡:⟜(↯∞_2/⊂⇌⍉≡(⊢⊚⌕)Prep:¤)P
| ⊡:⟜(⍉⇌↯2_∞/⊂≡(⊢⊚⌕):¤)P
)
°Bifid.Bifid. "This is it"
°Bifid.Bifid. "The invasion will start on the first of January"
</syntaxhighlight>
{{out}}
<pre>
"This is it"
"SSSTRIII"
"THISISIT"
"The invasion will start on the first of January"
"SYLCTMQCQISSVROQQPBTFHVRNWNTDSOFGTSGCQU"
"THEINVASIONWILLSTARTONTHEFIRSTOFIANUARY"
</pre>
===Extended===
26 letters and 10 digits = 36 chars, so that's the obvious extension. Plus super-security is guaranteed by adding the use of a codeword in the grid :-)
<syntaxhighlight lang="uiua">
S ← "GLYPHABCDEFIJKMNOQRSTUVWXZ0123456789"
P ← ↯⊟.√⧻.S
Prep ← ▽∊:S.⌵
Bifid ← setinv(
⊡:⟜(↯∞_2/⊂⇌⍉≡(⊢⊚⌕)Prep:¤)P
| ⊡:⟜(⍉⇌↯2_∞/⊂≡(⊢⊚⌕):¤)P
)
°Bifid.Bifid. "This is it"
°Bifid.Bifid. "The invasion will start at 0600 on the 1st of January"
</syntaxhighlight>
{{out}}
<pre>
"This is it"
"O556REEE"
"THISISIT"
"The invasion will start at 0600 on the 1st of January"
"OWV58W5CQY6MM1OUD2AU4NLDRSMSGUPRV80NL1TDYRR"
"THEINVASIONWILLSTARTAT0600ONTHE1STOFJANUARY"
</pre>
=={{header|Wren}}==
=={{header|Wren}}==
One way of enabling all 26 letters to be encrypted uniquely would be to use a 6 x 6 Polybius square including the 10 digits. We could then encrypt text using numerals as well.
One way of enabling all 26 letters to be encrypted uniquely would be to use a 6 x 6 Polybius square including the 10 digits. We could then encrypt text using numerals as well.