Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
33
Task/Chaocipher/Raku/chaocipher.raku
Normal file
33
Task/Chaocipher/Raku/chaocipher.raku
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
my @left;
|
||||
my @right;
|
||||
|
||||
sub reset {
|
||||
@left = <HXUCZVAMDSLKPEFJRIGTWOBNYQ>.comb;
|
||||
@right = <PTLNBQDEOYSFAVZKGJRIHWXUMC>.comb;
|
||||
}
|
||||
|
||||
sub encode ($letter) {
|
||||
my $index = @right.first: $letter.uc, :k;
|
||||
my $enc = @left[$index];
|
||||
$index.&permute;
|
||||
$enc
|
||||
}
|
||||
|
||||
sub decode ($letter) {
|
||||
my $index = @left.first: $letter.uc, :k;
|
||||
my $dec = @right[$index];
|
||||
$index.&permute;
|
||||
$dec
|
||||
}
|
||||
|
||||
sub permute ($index) {
|
||||
@left.=rotate: $index;
|
||||
@left[1..13].=rotate;
|
||||
@right.=rotate: $index + 1;
|
||||
@right[2..13].=rotate;
|
||||
}
|
||||
|
||||
reset;
|
||||
say 'WELLDONEISBETTERTHANWELLSAID'.comb».&encode.join;
|
||||
reset;
|
||||
say 'OAHQHCNYNXTSZJRRHJBYHQKSOUJY'.comb».&decode.join;
|
||||
Loading…
Add table
Add a link
Reference in a new issue